how to use class methods?

Mike 'Cat' Perkonigg blablu at gmx.net
Mon Sep 25 05:49:50 EDT 2000


sholden at BellAtlantic.net (Steve Holden) wrote in
<39CE53CE.F397AEFF at holdenweb.com>: 

>Christopher Paulicka wrote:
>> 
>> "Mike 'Cat' Perkonigg" <blablu at gmx.net> wrote in message
>> news:8FB776878mikecat at 192.168.10.38...
>> > Hi!
>> >
>> > How can I create a class method?
>> >
>> 
>> Well, you can't in the way you are thinking.
>> Any method inside the class definition is assumed to be an instance
>> method. 
>> 
>Surely, if a method is defined as part of a class definition then it
>will be a method of the class as well as a method of any instances
>created from that class definition?
>
>The gotcha is that a call on the method as a class method must give an
>explicit instance as a first argumnet, since it will be interpreted as
>an unbound method (i.e. one not associated automatically with a
>particular instance used to invoke it):

That is the problem. I tried to reveal some informations (base classes in
this case) without creating an instance. My problem is a bit tricky, but
the solution by having an external fuction reading the class information
is the best. I'm that deep in OO that I haven't thought about an external
function myself :-) 

Thanks,
Mike



More information about the Python-list mailing list