On 5 Juni, 11:02, ai <[EMAIL PROTECTED]> wrote: > 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. [...]
Well, in a sense I guess all reserved words can be considered magic, but in Python you can kill it (AFAIK that is pretty unique to python): >>> a = int(8) >>> int = float >>> b = int(8) >>> (a, b) (8, 8.0) I guess the amount and flavor of the magic is a matter of personal taste - coming from a C*-background I pretty much like myClass.myClass() instead of myClass.__init__() - but these are equivalent and I guess I just have to live with the way python has __special__ names and print a list of the cases I end up with often to keep my memory from forgetting them. > There are some special names even in Lisp. I guess you just hate the > '__'. Yes and no. Indeed, I find the overuse of underscores ugly, but I can accept some use of __special__ functions. AFAIK there must be reserved words in a programming language - f.x. names of ctors in oo-languages. The exceptions are perhaps brainf**k and whitespace that has special chars instead. Also I find it unfortunate that the name mangling and underscores are the way to make members "less public". But I can live with that - I just have to read more python code to get the hang of it. [:)]-|--< /Per -- Per Erik Strandberg home: www.pererikstrandberg.se work: www.incf.org also: www.spongswedencare.se > > On Jun 4, 2:43 pm, per9000 <[EMAIL PROTECTED]> 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 -- http://mail.python.org/mailman/listinfo/python-list
