Expression problem.
Peter Otten
__peter__ at web.de
Wed Oct 6 05:53:38 EDT 2010
Sebastiaan de Haan wrote:
> Thank you Chris,
>
> I'll try and find the attribute in the code. That was my conclusion
> aswell... The original author must have defined it somewhere...
Don't forget to check whether the object's class (or any of its bases) has a
__getattr__() or __getattribute__() method.
>>> class A(object):
... def __getattr__(self, name):
... return 42
...
>>> a = A()
>>> a.as
File "<stdin>", line 1
a.as
^
SyntaxError: invalid syntax
Note tha you can still access such an attribute using getattr()
>>> getattr(a, "as")
42
Peter
More information about the Python-list
mailing list