Hi!

I think I found something: There seems to be a difference between a
class and a type.

My approach was to let the __getattr__ method print the name of the
requested attribute. So:

class FOO:
    def __getattr__(self, a):
        print a
        if a=='__members__':
            return ['foo','bar']

Both in the notebook and on the command line, when I did dir(f) or
f.f<tab> or s.completions('f.f',globals(),system='python'), the
attributes "__members__" and "__methods__" where requested. In
addition, "traitnames" was requested for completion (but not for
dir(f)).

When I do the same for my real application, the picture is different.
Let H be an instance of my class.
- dir(H) uses the __dir__ method of my class. So, "__members__" isn't
needed.
- H.f<tab> requests trait_names twice and _getAttributeNames twice.
But it also calls the __dir__ method and thus yields the correct
result.
- s.completions('H.f',...) *only* requests trait_names, but
trait_names isn't implemented.

So, clearly f and H are treated differently. Perhaps that's the
reason:
sage: type(f)
<type 'instance'>
sage: type(H)
<class 'pGroupCohomology.cohomology.COHO'>

So, one is a type, the other is a class.

Probably, the easiest for me is to provide a trait_names method.

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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to