Get source (??) bug

48 views
Skip to first unread message

Neil Penning

unread,
Aug 7, 2020, 12:45:15 PM8/7/20
to sage-devel
In my init.sage folder, I have a class called Triangle_Numbers, which implements some basic functionality.

Unfortunately, it seems that anything in my sage.init folder is not accessible to ??, the get source command. Objects and functions defined by either sage or the user in the same session do work.

Anything I can do to work around this? Could someone point me to where the code for ?? is?
Screen Shot 2020-08-07 at 12.41.04 PM.png

Markus Wageringel

unread,
Aug 9, 2020, 5:18:23 AM8/9/20
to sage-devel
This is not related to the init.sage file, but to the fact that TriangleNumbers is a class. You can reproduce the problem like this

sage: class TriangleNumbers:
....:     pass
sage: import inspect
sage: inspect.getsourcelines(TriangleNumbers)
...
TypeError: <class '__main__.TriangleNumbers'> is a built-in class

which is what gets called in `sage.misc.sageinspect`. On the other hand, for functions defined in the init.sage file, inspection works as usual. This is an IPython feature, which is not directly implemented in Sage. There is an IPython issue for the problem with classes: https://github.com/ipython/ipython/issues/11249


Reply all
Reply to author
Forward
0 new messages