From: Rene Veerman on
hi.

i need to know the type of variable i'm dealing with.

take this list:

files = [
"lib/jquery/jquery-1.4.2.source.js",
"lib/jquery-ui-1.8.1/development-bundle/ui/jquery-ui-1.8.1.custom.js",
"lib/jquery-ui-1.8.1/development-bundle/ui/jquery.ui.tabs.js",
"lib/jquery/jquery.scrollTo-min.js",
"lib/jquery/jquery.corner.js",
"lib/jquery/jquery.mousewheel.js",
"lib/jquery/jquery.em.js",
"lib/jquery/jScrollPane.js",
"lib_rv/logAndHandler-1.1.0/lah.source.js",
"lib_rv/visCanvasLoaderIcon-1.1.0/visCanvasLoaderIcon.source.js",
self.getJavascript_getbootJSPHP,
"js/mbCore_boot.js",
"content/mediaBeez_custom.js"
]
# output a list of the files.
html = '';
for i in range(len(files)):
file = files[i]

f = open (file, 'r')
html += f.read()

page = {
'html' : html
}
the third-last item in the list is not a string, it's a function.
how do i test for that?

--
---------------------------------
Greetings from Rene7705,

My free open source webcomponents:
  http://code.google.com/u/rene7705/
  http://mediabeez.ws/downloads (and demos)

My music (i'm DJ firesnake)
  http://mediabeez.ws/music

http://www.facebook.com/rene7705
---------------------------------
From: Mark Lawrence on
On 11-7-2010 14:23, Rene Veerman wrote:
> hi.
>
> i need to know the type of variable i'm dealing with.
>
> take this list:
>
> files = [
> "lib/jquery/jquery-1.4.2.source.js",
> "lib/jquery-ui-1.8.1/development-bundle/ui/jquery-ui-1.8.1.custom.js",
> "lib/jquery-ui-1.8.1/development-bundle/ui/jquery.ui.tabs.js",
> "lib/jquery/jquery.scrollTo-min.js",
> "lib/jquery/jquery.corner.js",
> "lib/jquery/jquery.mousewheel.js",
> "lib/jquery/jquery.em.js",
> "lib/jquery/jScrollPane.js",
> "lib_rv/logAndHandler-1.1.0/lah.source.js",
> "lib_rv/visCanvasLoaderIcon-1.1.0/visCanvasLoaderIcon.source.js",
> self.getJavascript_getbootJSPHP,
> "js/mbCore_boot.js",
> "content/mediaBeez_custom.js"
> ]
> # output a list of the files.
> html = '';
> for i in range(len(files)):
> file = files[i]
You could write for file in files:
*BUT* using file will override the builtin name, better (say)
for fn in files:
>
> f = open (file, 'r')
hence:- f = open (fn, 'r')
> html += f.read()
>
> page = {
> 'html' : html
> }
> the third-last item in the list is not a string, it's a function.
> how do i test for that?
>
Check out the isinstance function here.
http://docs.python.org/library/functions.html

HTH.

Mark Lawrence