[Python-Dev] Class Methods

Thomas Heller thomas.heller at ion-tof.com
Mon Apr 23 10:02:54 EDT 2001


"Greg Ewing" <greg at cosc.canterbury.ac.nz> wrote:
> Guido:
>
> > The problem is that if you write C.spam, there could be two spams: one
> > in C.__dict__, one in M.__dict__.  Which one to use?  How does
> > Smalltalk resolve this?
>
> The problem doesn't arise in Smalltalk, because method calls and
> instance variable accesses are completely different things and are
> handled by quite separate syntaxes and mechanisms.
>
> Python creates problems for itself here by confusing instance
> variables of the class with metadata about the instance's methods,
> and keeping them both in the same namespace.
True.

>
> Thomas Heller <thomas.heller at ion-tof.com>:
>
> > I'm walking on thin ice here (maybe I should better try it out),
> > but IIRC Smalltalk requires to explicit:
> >
> >     self class method;
> > or
> >     self method;
>
> No, to call a class method in Smalltalk, you just send a message
> to the class itself rather than an instance. There's no difference
> in the message sending syntax.

My example shows how to send a message to the _class_ of an object.
You can, of course, do it directly:

Class method;

Thomas





More information about the Python-list mailing list