Do I need "self" and "other"?
Nick Dumas
drakonik at gmail.com
Sat Jun 28 14:00:00 EDT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Peter Pearson wrote:
> 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
>
Yeah, looking back at that...bleh. Not a smart typo. But I did run the
- -proper- code, and I learned a little bit about Python and classes.
Sorry for the typo, folks.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkhmfB8ACgkQLMI5fndAv9gAWgCcDjDIVhHAHDT4r/K8iPqoJALv
HRIAnRgT5KELazbf42Y3084zwQlZ/fJt
=vE7Z
-----END PGP SIGNATURE-----
More information about the Python-list
mailing list