magic names in python
josiah.carlson at sbcglobal.net
Mon Jun 4 09:18:51 CEST 2007
> So my questions:
> * is there a comprehensive list of magic names in python (so far i
> know of __init__ and __repr__)?
> * are these lists complete or can magic names be added over time (to
> the python "core")?
> * are magic names the same in different python versions?
I don't believe that there is a full list of all __magic__ methods. The
operator module has a fairly extensive listing of functions that call
such methods, but I know that some have been left out.
Among those that I remember off the top of my head while typing this
__cmp__ (__eq__, __ne__, __lt__, __gt__, __le__, __ge__)
There's also the not-magic named, but still somewhat magic .next()
method on iterators/generators.
More information about the Python-list