Re: magic names in python

2007-06-05 Thread Lenard Lindstrom
Steven D'Aprano wrote: > On Tue, 05 Jun 2007 18:08:31 +, Lenard Lindstrom wrote: > >> Steven D'Aprano wrote: >>> On Mon, 04 Jun 2007 22:19:35 +, Lenard Lindstrom wrote: >>> What is "magic" about __init__ and __repr__? They are identifiers just like "foo" or "JustAnotherClass". T

Re: magic names in python

2007-06-05 Thread Steven D'Aprano
On Tue, 05 Jun 2007 18:08:31 +, Lenard Lindstrom wrote: > Steven D'Aprano wrote: >> On Mon, 04 Jun 2007 22:19:35 +, Lenard Lindstrom wrote: >> >>> What is "magic" about __init__ and __repr__? They are identifiers just >>> like "foo" or "JustAnotherClass". They have no special meaning to

Re: magic names in python

2007-06-05 Thread Lenard Lindstrom
Steven D'Aprano wrote: > On Mon, 04 Jun 2007 22:19:35 +, Lenard Lindstrom wrote: > >> What is "magic" about __init__ and __repr__? They are identifiers just >> like "foo" or "JustAnotherClass". They have no special meaning to the >> Python compiler. The leading and trailing double underscore

Re: magic names in python

2007-06-05 Thread per9000
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 yo

Re: magic names in python

2007-06-05 Thread ai
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, per

Re: magic names in python

2007-06-05 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, per9000 wrote: > 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*

Re: magic names in python

2007-06-05 Thread per9000
On 4 Juni, 10:19, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> 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 onc

Re: magic names in python

2007-06-04 Thread Steven D'Aprano
On Mon, 04 Jun 2007 22:19:35 +, Lenard Lindstrom wrote: > What is "magic" about __init__ and __repr__? They are identifiers just > like "foo" or "JustAnotherClass". They have no special meaning to the > Python compiler. The leading and trailing double underscores represent > no special inca

Re: magic names in python

2007-06-04 Thread Lenard Lindstrom
per9000 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 disco

Re: magic names in python

2007-06-04 Thread Facundo Batista
Josiah Carlson wrote: > I don't believe that there is a full list of all __magic__ methods. The > operator module has a fairly extensive listing of functions that call > such methods, but I know that some have been left out. There IS a full documentation of this special methods:: http://doc

Re: magic names in python

2007-06-04 Thread markacy
On 4 Cze, 08:43, 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 (

Re: magic names in python

2007-06-04 Thread Diez B. Roggisch
per9000 wrote: > On Jun 4, 9:11 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> In <[EMAIL PROTECTED]>, per9000 >> wrote: >> > >> > [...] >> > >> > So another question emerges: >> > * is the use of magic names encouraged and/or part of good coding >> > practice. >> >> What do you mean

Re: magic names in python

2007-06-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, per9000 wrote: > On Jun 4, 9:11 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> In <[EMAIL PROTECTED]>, per9000 wrote: >> > >> > [...] >> > >> > So another question emerges: >> > * is the use of magic names encouraged and/or part of good coding >> > practice. >>

Re: magic names in python

2007-06-04 Thread per9000
On Jun 4, 9:11 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, per9000 wrote: > > > > [...] > > > > So another question emerges: > > * is the use of magic names encouraged and/or part of good coding > > practice. > > What do you mean by "use"? Implement them to o

Re: magic names in python

2007-06-04 Thread Josiah Carlson
per9000 wrote: > 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 don'

Re: magic names in python

2007-06-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, per9000 wrote: > I just used a search engine a little on this topic and I found no > comprehensive list of magic names in python. They are usually mentioned in parts of the docs where the relevant functionality is explained. For example in `Special method names`_ in the r