On 18 August 2010 13:52, Robert Bradshaw <[email protected]> wrote:
> On Wed, Aug 18, 2010 at 9:50 AM, Lisandro Dalcin <[email protected]> wrote:
>> On 18 August 2010 12:53, Carl Witty <[email protected]> wrote:
>>>
>>> Although I'm actually in favor of just leaving the post-#561 status,
>>> where __getattr__ remains unavailable to Python, using the "cdef
>>> classes are different" rationale.
>>>
>>
>> What about cheating and generating special code in Cython's
>> __getattribute__ to special case the "__getattr__" attribute and
>> return something useful?
>
> I'm not following you here. We currently create a __getattribute__
> using the __getattr__ method, this is just a question of exposing the
> unbound method to Python space.
>

cdef Foo:
   def __getattr__(self, name):
       ...

def Foo_getattr_hook(obj, name):
     try:
         attr = Foo_getattr(obj, name) # this is the user defined code
in Foo.__getattr__()
    except AttributeError:
        if name == '__getattr__':
             return bound_getattr_method(obj)
        else:
            raise

....

Foo.tp_getattro = Foo_getattr_hook


Too easy... I'm likely missing something...
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to