magic names in python

per9000 per9000 at gmail.com
Tue Jun 5 03:14:14 EDT 2007


On 4 Juni, 10:19, Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:
>
> [...]
>
> Now I'm a little confused.  What does this have to do with magic names?  I
> thought you are talking about names that start and end with two
> underscores (`__magic__`)!?

Indeed I am talking about two things at once - you are right. Since I
have problems with both of these "features" I perhaps do not separate
them very well.

I received lots of nice links to __special__ names in python, thanks.
When it comes to 'dive into python' this is like the fifth time I
heard of it so I really have to get it soon.

Still, I have problems with "magic" functions, similar to magic
numbers: http://en.wikipedia.org/wiki/Magic_number_%28programming%29
f.x. calling all member-functions of a class to close files as
illustrated in a previous post, or PyUnits magic "test*"-names:
http://pyunit.sourceforge.net/pyunit.html#RUNNING_CMD (there are
options here but I fell into the bear-trap of course)

Guessing from your replies this is a general problem/issue/feature and
as I understand it there is no special pythonic recommendations in
this area, right?

Also, I guess that use of magic numbers and magic should be documented
and are thus discovered by RTFM'ing.

Additional comments are welcome, or course.

All your base are belong to us,
Per

--

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




More information about the Python-list mailing list