0
how to use magic methods (delitem and setitem) in python?
I don't know how they are used, one is supposed to clear values but I don't know how to activate them
2 odpowiedzi
+ 6
__setitem__ and __delitem__ implementation or implement those methods like e.g.
def __setitem__(self, key, value):
"""
:raise: Always.
:raises: TypeError
"""
self.data_set[key] = value # Raise from tuple.
def __delitem__(self, key):
"""
:raise: Always.
:raises: TypeError
"""
raise TypeError("Item deletion is unsupported")
+ 5
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2470/?ref=app
If you need help, link your ACTUAL CODE and explain what exactly you want to do.