magic names in python

ai ai.nature at gmail.com
Tue Jun 5 05:02:29 EDT 2007


I don't think it is magic. If you think it is magic, can you talk
about what's the better way and how can you implement the functions
without any magic. I can't image a lauguage without special names.
There are some special names even in Lisp. I guess you just hate the
'__'.

On Jun 4, 2:43 pm, per9000 <per9... at gmail.com> wrote:
> 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