class object access in class definition?
Lars Damerow
lars at pixar.com
Tue Mar 6 19:03:14 EST 2001
Hi folks!
Is it possible to reference a class from within its own definition? Something
along the lines of:
class Foo:
print Foo
This works for functions--that is,
>>> def foo():
... print foo
...
>>> foo()
<function foo at 0x8111024>
works as expected, but the class definition above raises a NameError:
>>> class Foo:
... print Foo
...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 2, in Foo
NameError: There is no variable named 'Foo'
Thanks for any pointers!
-lars
___________________________________________________________
lars damerow
senior unix administrator
pixar animation studios
lars at pixar.com
"Nauseous. Nauseated. The first means 'sickening to contemplate'; the second
means 'sick at the stomach.' Do not, therefore, say, "I feel nauseous," unless
you are sure you have that effect on others."
- William Strunk Jr., "The Elements of Style"
More information about the Python-list
mailing list