[Tutor] variables question.

Jeff Honey jeffh at pona.net
Wed Nov 10 19:21:45 CET 2010


I have a question about where variables are exposed in python.

I have a monolothic script with a number of functions defined, can those functions share variables? can I instantiate them outside the function of where they are needed? do they need to be wrapped in quotes, ever? For example:

blah = 123
foo = 'somestring'

def function(foo):
    code that needs foo
    anotherfunction(blah) 

def anotherfunction(blah):
    code that needs blah
    code that uses foo

....how about this:

def function(blah, foo):
    anotherfunc(blah)
    anotherfunc(foo)

...what about my python being called from some parent script (something OTHER than python) that instantiates blah and foo FOR me? Can I just plug those into my code like I would normally? I guess this is more about HOW and WHERE I can make variables available for use.

--
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
¤ kyoboku kazeoshi ¤
 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


More information about the Tutor mailing list