In Python, if I define a variable:
my_var = (1,2,3)
and try to access it in __init__ function of a class:
class MyClass:
def __init__(self):
print my_var
I can access it and print my_var without stating (global my_var).
If I put my_var right after class MyClass however, I get scope error (no global variable found).
What is the reason for this? How should I do this? Where can I read about this to learn? I did read Python Class page but I did not encounter its explanation.
Thank you