上传文件至「week12」
This commit is contained in:
34
week12/ex7.py
Normal file
34
week12/ex7.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from continueanyway import ca
|
||||
|
||||
def handleAttrError(lmbd):
|
||||
def NoneR(*args,**kwargs):
|
||||
return None
|
||||
def runlambda(*args,**kwargs):
|
||||
try:
|
||||
return lmbd(*args,**kwargs)
|
||||
except AttributeError:
|
||||
print("AttributeError detected!")
|
||||
return NoneR
|
||||
return runlambda
|
||||
|
||||
class listIE(list):
|
||||
def __init__(self, iterable):
|
||||
super().__init__(iterable)
|
||||
|
||||
@handleAttrError
|
||||
def __getattribute__(self, name):
|
||||
return super().__getattribute__(name)
|
||||
|
||||
@handleAttrError
|
||||
def __call__(self, *args, **kwds):
|
||||
return super().__call__(*args, **kwds)
|
||||
|
||||
def main():
|
||||
l1 = listIE([1,2,3])
|
||||
print(l1.popp(1))
|
||||
print(l1.pop(1))
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user