私が使用しているいくつかのレガシーコードは機能します[コードは問題を再現するコードに置き換えられました]:
class foo:
pass
class bar(foo):
def __new__(cls):
global BIZ
if BIZ is not None:
pass
bar()
しかし、私がそれを変更すると
class foo(object):
次に、Pythonは次のように出力します。
Traceback (most recent call last):
File "test.py", line 11, in <module>
bar()
File "test.py", line 8, in __new__
if BIZ is not None:
NameError: global name 'BIZ' is not defined
どうしてこれなの?