confused about self, why not a reserved word?

Diez B. Roggisch deets at nospam.web.de
Mon May 5 08:37:23 EDT 2008


globalrev wrote:

> class Foo(object):
> def Hello(self):
> print "hi"
> 
> object is purple, ie some sort of reserved word.

It is not.
 
> why is self in black(ie a normal word) when it has special powers.
> replacing it with sel for example will cause an error when calling
> Hello.

That must be some other problem. This is perfectly legal python code and
works:

class Foo(object):
    def bar(imafancyobject):
        print imafancyobject

f = Foo()
f.bar()

Diez



More information about the Python-list mailing list