Steven D'Aprano, et al,
Thanks everyone for the thorough explanations on variable use and scope in
Python. It was enlightening...and sometimes confusing, but I'm working on that.
It just points out all the new things I have yet to learn about the language.
--
¤¤
¤ kyoboku kazeo
Jeff Honey wrote:
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?
It's pretty typical for scoping rules. If you define variables outside of your
funcs you can access them inside the func. If you want to change the value in
the function you need to declare the scope as global. If you make another
variable with the same name inside of a function it will shadow t
On 11/10/2010 10:21 AM Jeff Honey said...
I have a question about where variables are exposed in python.
You're looking for scoping rules -- see for example
http://stackoverflow.com/questions/291978/short-description-of-python-scoping-rules
where they get into some detail, but the short and o
"Jeff Honey" wrote
I have a question about where variables are exposed in python.
Take a look at the namespaces topic in my tutor for more details
but...
I have a monolothic script with a number of functions defined,
can those functions share variables?
Yes but its usually bad practice
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