Do I need "self" and "other"?

Peter Pearson ppearson at nowhere.invalid
Sat Jun 28 13:36:30 EDT 2008


On Fri, 27 Jun 2008 20:19:00 -0400, Nick Dumas <drakonik at gmail.com> wrote:
[snip]
>
> Example:
>
> class Foo():
> 	self.x = 5


Have you tried what you're posting?

Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo():
  File "<stdin>", line 1
    class Foo():
              ^
SyntaxError: invalid syntax
>>> class Foo( object ):
...   self.x = 5
...
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 2, in Foo
NameError: name 'self' is not defined
>>>

-- 
To email me, substitute nowhere->spamcop, invalid->net.



More information about the Python-list mailing list