magic names in python
per9000 at gmail.com
Mon Jun 4 08:43:56 CEST 2007
I recently started working a lot more in python than I have done in
the past. And I discovered something that totally removed the pretty
pink clouds of beautifulness that had surrounded my previous python
experiences: magic names (I felt almost as sad as when I discovered
the strange pink worms that eat you in nethack, not to mention the
mind flayers - I really hate them).
I guess all programming languages have magic names to some extent
(f.x. classes in the "C-family" have constructors that must have the
same name as the class (foo::foo) instead of foo.__init__).
I just used a search engine a little on this topic and I found no
comprehensive list of magic names in python.
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 also tried (selected parts of(?)) the unittest package for use in
Zope and it seemed functions that I created for my test with the magic
prefix "test" were magic, other functions were not.
So another question emerges:
* is the use of magic names encouraged and/or part of good coding
Live long and prosper,
Per Erik Strandberg
More information about the Python-list