In Python, if I define a variable:
my_var = (1,2,3)
and try to access it in the class __init__ function:
class MyClass: def __init__(self): print my_var
I can access it and print my_var without specifying (global my_var).
If I put my_var right after the class MyClass , I get a scope error (no global variable found) .
What is the reason for this? How can I do it? Where can I read about this to find out? I read the Python class page, but I did not find an explanation.
thanks
source share