magic names in python

per9000 per9000 at gmail.com
Mon Jun 4 08:43:56 CEST 2007


Hi,

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
practice.

Live long and prosper,
Per

--

Per Erik Strandberg
home: www.pererikstrandberg.se
work: www.incf.org
also: www.spongswedencare.se




More information about the Python-list mailing list