cls & self

Chris Mellon arkanes at gmail.com
Fri Jul 27 08:16:39 EDT 2007


On 7/27/07, Diez B. Roggisch <deets at nospam.web.de> wrote:
> james_027 schrieb:
> > hi,
> >
> > is cls & self the same thing?
> >
> > I have seen something like
> >
> > class A:
> >     def dosomething(cls):
> >        #doing something
> >
> > How is cls & self differ? How is it use?
>
> cls and self are just names. And you most certainly haven't seen the
> above, but this instead:
>

Quite likely he has seen this, except there followed many other lines and then
dosomething = classmethod(dosomething) at the end.

This disjoint between where it's declared (and looks like a method)
and where it's set to a classmethod was a primary factor behind the
decorator syntax, of course.



More information about the Python-list mailing list