I'm also very mistified. It is actually very hard to remove a method form a 
cdef'ed class. I tried some stuff to recreate the symptoms but I failed 
missarably (I could do it in pure python using del or metaclasses but not 
in cython).

What happens if you subclass Parent with a cdef class? Does __getattr__ 
appear then? And what if you define __getattr__ in this subclass? And what 
happens if you subclass sage.structure.category_object.CategoryObject (the 
superclass of Parent)? 

I looked at sage/structure/parent.pyx and it's size sort of scared me 
because it's so huge so maybe it's good to try to persuade the above 
questions to find a smaller example.

Le vendredi 27 avril 2012 17:03:22 UTC+2, Simon King a écrit :
>
> Hi John! 
>
> On 2012-04-27, John Cremona <john.crem...@gmail.com> wrote: 
> > It has __getattribute__ (as you can see by doing 
> > sage.structure.parent.Parent.__<tab> 
>
> Yes, but that is not defined in sage.structure.parent or 
> sage.structure.category_object. 
>
> Anyway: Would the existence of __getattribute__ explain why __getattr__ is 
> not available as an attribute, even though it is defined and is used? 
>
> Apparently not: 
>
>   sage: cython(""" 
>   ....: cdef class Example(object): 
>   ....:     def __getattr__(self, str name): 
>   ....:         return 1 
>   ....: """) 
>   sage: Example.__get<TAB> 
>   Example.__getattr__       Example.__getattribute__   
>   sage: Example.__getattr__ 
>   <method '__getattr__' of 
> '_home_simon__sage_temp_linux_sqwp_site_2778_tmp_0_spyx_0.Example' objects> 
>
> So, there is a __getattribute__, but still one can access __getattr__. 
>
> And apparently it is not a Python thing - or at least it isn't a Cython 
> thing, since otherwise my example wouldn't work. 
>
> Cheers, 
> Simon 
>
>

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to