[Tutor] q about method(self)
Gregor Lingl
glingl@aon.at
Sun, 01 Sep 2002 09:38:02 +0200
Erik Price schrieb:
> A class method generally takes "self" as its first argument. I had
> been wondering for some time why this is, since it seems redundant if
> it's there for all class methods. But I just realized -- you can call
> an object's method without using dot notation in Python, like this:
>
> method(instance_reference, args)
>
> rather than only like this:
>
> instance_reference.method(args)
>
> I didn't realize that until just now. But what I'm wondering is,
> why/when would you want to use this form? Is it just an aesthetic
> thing, or is it something that is required b/c of the way that Python
> handles user-defined classes and objects? Or something else?
>
> One other quickie question -- not that I would ever need to do this,
> but could a different identifier other than "self" ever be used?
> (such as "this") It -appears- that "self" is just a reference within
> a class, but perhaps there's magic going on that I don't know about.
>
some weeks ago I posted a message, which adresses several aspects
of your question. You may find it here:
http://mail.python.org/pipermail/tutor/2002-August/016395.html
Regards, Gregor
>
>
> Thanks,
>
> Erik
>
>
>
>
>
> --
> Erik Price
>
> email: erikprice@mac.com
> jabber: erikprice@jabber.org
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>