Confused with methods

Antoon Pardon apardon at forel.vub.ac.be
Wed Feb 9 03:14:01 EST 2005


Op 2005-02-08, Diez B. Roggisch schreef <deetsNOSPAM at web.de>:
>> No python is not consistent and your continuous repetion doesn't
>> make it so. To illustrate, here the following code:
>> 
>> class A:
>>   l = []
>>   def f(): pass
>> 
>> a = A()
>> print a.l is A.l
>> print a.f is A.f
>> 
>> which produces:
>> 
>> True
>> False
>
> Thats only inconsistent from your POV because you refuse to accept that the
> scope of a function definition does matter.

It doesn't. As Alex has already explained, the above is equivallent to:

def h(): pass

class A:
  l = []
  f = h

a = A()
print a.l is A.l
print a.f is A.f


And such great error would surely brand you a Troll in his eyes.
Scope of definition has nothing to do with it. The only factor
that matters in this case is if the function is a class atribute
or not.

> And as usual its a topic of
> totally unrelevant practical impact and an expression of your strangely
> deeprooted desire to nitpick at such unrelevant details. 

If I told you that this detail, well not this particular one but
one that is close to it, will break one of my applications in
the transition from python 2.3 to 2.4, do you still think
it is irrelevant?

I would also argue that if a particular detail is a stumbling block
for someone to understand something it is not that irrelevant
and that claiming something is inconsistent while it is not,
is not a good way to remove such a stumbling block.


> Why don't you pick something that really bothers people and see if your
> skills (that I'm sure exist) can be of use there?

This did bother someone, it was a stumbling block for him understanding
what was going on.

-- 
Antoon Pardon



More information about the Python-list mailing list