Barry Kelly <[EMAIL PROTECTED]> wrote:
> From "pydoc __getattribute__":
>
> ---8<---
> Help on method-wrapper object:
>
> __getattribute__ = class method-wrapper(object)
> | Methods defined here:
> |
> | __call__(...)
> | x.__call__(...) <==> x(...)
> |
> | __getattribute__(...
Barry Kelly wrote:
[snipped]
> Yet when I try this with the 'type' type, it doesn't work:
>
> ---8<---
> >>> x.__class__.__class__
>
> >>> x.__class__.__getattribute__('__class__')
> Traceback (most recent call last):
> File "", line 1, in ?
> TypeError: descriptor '__getattribute__' requires a
Barry Kelly a écrit :
> I'm running this version of Python:
>
> Python 2.4.3 (#1, May 18 2006, 07:40:45)
> [GCC 3.3.3 (cygwin special)] on cygwin
>
> I read in the documentation that these two expressions are
> interchangeable:
>
> x.__getattribute__('name') <==> x.name
I wouldn't say th
Barry Kelly wrote:
> I read in the documentation that these two expressions are
> interchangeable:
> x.__getattribute__('name') <==> x.name
I think you'll find:
getattr(x, 'name') <==> x.name
is what is equivalent. You can define a '__getattribute__'
method which will get used, bu
Le Mardi 20 Juin 2006 18:36, Barry Kelly a écrit :
> Yet when I try this with the 'type' type, it doesn't work:
>
> ---8<---
>
> >>> x.__class__.__class__
>
>
>
> >>> x.__class__.__getattribute__('__class__')
>
you're looking for getattr :
In [11]: getattr(object, '__class__')
Out[12]:
In [13]:
I'm running this version of Python:
Python 2.4.3 (#1, May 18 2006, 07:40:45)
[GCC 3.3.3 (cygwin special)] on cygwin
I read in the documentation that these two expressions are
interchangeable:
x.__getattribute__('name') <==> x.name
>From "pydoc __getattribute__":
---8<---
Help on method-