doctest를 수행하기 위해 Python 3.5를 사용하고 있습니다. 오류가 항상있다 :Python 3.5 : TypeError : __init __()에서 예상치 못한 키워드 인자 'nosigint'가 발생했습니다.
File "D:\Program Files\Anaconda\lib\doctest.py", line 357, in __init__
pdb.Pdb.__init__(self, stdout=out, nosigint=True)
TypeError: __init__() got an unexpected keyword argument 'nosigint'
내 자신의 코드에 오류가 doctest.py 파일에서 발생하는 것으로 보인다 있지만.
dict와 비슷한 클래스를 정의하고 싶습니다. 내 코드 :
class Dict(dict):
'''
Simple dict but also support access as x.y style.
>>> d1 = Dict()
>>> d1['x'] = 100
>>> d1.x
100
>>> d1.y = 200
>>> d1['y']
200
>>> d2 = Dict(a=1, b=2, c='3')
>>> d2.c
'3'
>>> d2['empty']
Traceback (most recent call last):
...
KeyError: 'empty'
>>> d2.empty
Traceback (most recent call last):
...
AttributeError: 'Dict' object has no attribute 'empty'
'''
def __init__(self, **kw):
super(Dict, self).__init__(**kw)
def __getattr__(self, key):
try:
return self[key]
except KeyError:
raise AttributeError(r"'Dict' object has no attribute '%s'" % key)
def __setattr__(self, key, value):
self[key] = value
if __name__=='__main__':
import doctest
doctest.testmod()
도와 주시겠습니까?
Spyder IDE를 사용하고 있습니다. 감사. – Dawn