次の例に基づいて、クラスが独自の名前空間に格納されているといつも思っていたので、クラス内から var xyz を出力できるようになりました。
xyz = 123
>>> class test:
... def __init__(self):
... pass
... def example(self):
... print xyz
...
>>> test().example()
123
ありがとう
次の例に基づいて、クラスが独自の名前空間に格納されているといつも思っていたので、クラス内から var xyz を出力できるようになりました。
xyz = 123
>>> class test:
... def __init__(self):
... pass
... def example(self):
... print xyz
...
>>> test().example()
123
ありがとう