当我尝试在默认参数中使用导入的__version_info
时,它会失败,任何想法我应该如何引用它?
from sys import version_info as __version_info
class Foo:
def __init__(self, name = "pepe" if __version_info[0] < 3 else "jose"):
self.name = name
这是错误
Traceback (most recent call last):
File "/home/jose/Documents/Test.py", line 4, in <module>
class Foo:
File "/home/jose/Documents/Test.py", line 5, in Foo
def __init__(self, name = "pepe" if __version_info[0] < 3 else "jose"):
NameError: name '_Foo__version_info' is not defined