What is the raison d'etre for Special/Magic Methods
maxm at mxm.dk
Wed Feb 6 15:33:50 EST 2002
> I know there is a section on this at www.diveintopython.org but the
> site has been down all afternoon.
Usually it is to create a "hook" into Python syntax.
ie. if you want to get content from a dictionary object you do:
result = someDict['someKey']
The somedict then will have a "__getitem__" method that returns "result".
regards Max M
More information about the Python-list