Message16341
Logged In: YES
user_id=589306
I tried running with current CVS and got the following
results on Linux:
Python 2.3b1+ (#3, Jun 13 2003, 07:56:14)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> class A:
... def __getattr__(self, name):
... return 3
...
>>> a = A()
>>> a.c
3
>>> class B:
... def __getattr__(self, name):
... print self, name
... return 3
...
>>> b = B()
>>> b.c
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 3, in __getattr__
File "<stdin>", line 3, in __getattr__
File "<stdin>", line 3, in __getattr__
File "<stdin>", line 3, in __getattr__
[Repeats lots of times]
File "<stdin>", line 3, in __getattr__
RuntimeError: maximum recursion depth exceeded
>>> class C:
... def __init__(self):
... self.x = 5
... def __getattr__(self, name):
... print self.x
... return 3
...
>>> c = C()
>>> c.c
5
3
$ uname -a
Linux localhost 2.4.20-18.9 #1 Thu May 29 06:54:41 EDT 2003
i686 athlon i386 GNU/Linux
-------------------------------------------------
Note that I can print things from getattr, it is just
printing self that gets me in trouble.
|
|
Date |
User |
Action |
Args |
2007-08-23 14:13:51 | admin | link | issue752221 messages |
2007-08-23 14:13:51 | admin | create | |
|