Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Confused with methods

Reply
Thread Tools

Confused with methods

 
 
Antoon Pardon
Guest
Posts: n/a
 
      02-09-2005
Op 2005-02-08, Diez B. Roggisch schreef <(E-Mail Removed)>:
>> 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
 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      02-09-2005
> 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


So what - the difference is between bound and unbound method, which is what
were talking here about after all - so in the end, its a question of how a
bound method gets created. I'm pretty sure there are plenty of other ways
to create one - try the new module, metaclasses and what not. But that they
exist and are different from unbound methods or functions is not
inconsistent. In the same spirit you could call instance methods in
languages like java or c++ inconsistent - as the have an implicit first
argument, which "normal" functions don't have. So either way round - its a
bit of magic for having oo-style method dispatch. If you want to get rid of
it, don't use OO or at least don't use classes. Nobody prevents you from
doing that.


> 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?


If its not _this_ detail, its not relevant for _this_ thread. And a general
assertion that transitional changes between versions of python create
problems might be worth a discussion - but that's not what were talking
about here. Instead, we're talking about inconsistencies in _one_ certain
version of python - inconsistencies that no one except you seems to
perceive.

>
> 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.


The OP very well understood the difference between bound and unbound
methods. His confusion was that there was no general currying mechanism
behind it that would create subsequent argument bindings if he stuffed a
method into another class. He now understands better.
> This did bother someone, it was a stumbling block for him understanding
> what was going on.


It did bother him because he didn't understand it in the first place - and
he now does understand it.

Well, I'm well prepared to agree to disagree with you on this. If you feel
its inconsistent, I'm not trying to convince you otherwise. But as I said
before: Even if it _is_ - its still of no practical impact. Also the OP
didn't have any further problems after seeing whats getting on. So lets
move along.

--
Regards,

Diez B. Roggisch
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to find the class methods of a class, just like'methods' finds the instance methods? Kenneth McDonald Ruby 5 09-26-2008 03:09 PM
Top-Up Methods - Finarea (Voipcheap, internetcalls, etc.) et. al., VOIP Services Question - Top-up Methods News Reader UK VOIP 0 04-10-2006 02:41 PM
Why Petshop Changed all static methods to instance methods when upgrading from version 3.0 to version 3.1? Neo ASP .Net 1 01-07-2005 01:46 AM
Really confused about authorization/authentication methods in ASP.Net STom ASP .Net Security 2 08-07-2003 08:45 AM
Re: Templates and friends and template methods with private methods. Buster Copley C++ 5 07-07-2003 12:50 AM



Advertisments