On Sat, Jul 31, 2010 at 2:32 PM, Simon King <[email protected]> wrote:
> I agree that this "error opening source code" sucks. The attitude to
> hide the code (and even the documentation, in some cases!) behind
> layers of abstraction seems a side-effect of the new category
> framework (perhaps not in this particular case, I don't know).
No, it is not. Introspection works fine with __getattr__. With the
following code,
def a_function():
return 'a function'
class PythonFooGetAttr:
def __getattr__(self, attr):
return a_function
I get
sage: f = PythonFooGetAttr()
sage: f.a_function??
Type: builtin_function_or_method
Base Class: <type 'builtin_function_or_method'>
String Form: <built-in function a_function>
Namespace: Interactive
Definition: f.a_function()
Source:
def a_function():
return 'a function'
The issue that you are seeing above is because RLF(3).sqrt is not
really a method. Look at the following
sage: a = RLF(3); a
3
sage: a.sqrt
1.732050807568878?
sage: type(a.sqrt)
<type 'sage.rings.real_lazy.LazyNamedUnop'>
sage: b = a.sqrt; b
sage: b()
1.732050807568878?
Introspection fails in the first case because you are trying to look
up the source code of an object. In these cases, the introspection
code will try to return the source code of the class of the object.
However, we have
sage: b.__class__.__doc__ is None
True
Cython should probably generate the file header ( "File:
sage/rings/integer.pyx (starting at line 417)\n\n", etc.) even when
the class does not have a docstring. Note that
sage: c = 3
sage: c??
works fine.
Again, please stop spreading FUD about the category code.
--Mike
--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org