두 파일 multitest.py 및 skiplist.py가 있습니다 우리는 편집 할 수없는 시작 코드로 skiplist.py가 제공됩니다.Python에서 가져온 파일의 코드 실행
multitest.py 내가 만들고 skiplist.py 파일에서
skiplist.py
에서 기능을 빌려되어있어 파일, 우리는 multitest에서class SkipList(object):
def __len__(self):
"""(SkipList) -> int
Return the number of items in this skip list.
"""
return self.size
같은 방법이있다. py, 나는 내 자신의 len 메서드를 만들어야하지만 내장 함수에 액세스 할 수는 없습니다.
from skiplist import *
class MultiSet(object):
def __len__(self):
"""(MultiSet) -> int
Return the number of items in this multiset.
"""
return SkipList.__len__(self)
s = MultiSet([])
print(len(s))
를 실행 내가 오류를
Traceback (most recent call last):
File "/Applications/WingIDE.app/Contents/MacOS/src/debug/tserver/_sandbox.py", line 134, in <module>
File "/Applications/WingIDE.app/Contents/MacOS/src/debug/tserver/_sandbox.py", line 56, in __len__
File "/Users/Borna/Documents/CSC148/Assignment/skiplist.py", line 39, in __len__
return self.size
builtins.AttributeError: 'MultiSet' object has no attribute 'size'
기술적으로'object'는 내장 ... – geoffspear