On Mon, 5 May 2008 04:57:25 -0700 (PDT), globalrev <[EMAIL PROTECTED]> wrote:
class Foo(object):
        def Hello(self):
                print "hi"

object is purple, ie some sort of reserved word.

What your text editor of choice does with syntax coloring is its own business.
It doesn't really have anything to do with the language, except inasmuch as one
might hope that it is *somehow* based on it.

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.

Not true.

   [EMAIL PROTECTED]:~$ python -c '
   > class Foo(object):
   >     def Hello(monkeys):
   >         print "hi"
   >
   > Foo().Hello()
   > '
   hi
   [EMAIL PROTECTED]:~$

`self´ as the name of the first parameter to an instance method is
convention; beyond that, it has no special meaning in the language.

`object´, on the other hand, is a builtin name which refers to a
particular object.

Jean-Paul
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to