Ask Your Question
0

List all available classes and functions

asked 2014-09-11 21:04:58 +0100

PerAlexandersson gravatar image

How can I get a list of all available classes and the corresponding methods in Sage?

The reason I ask is that I would like to create a syntax file for the editor Kate. I have not found one so far, if there is one, this would also solve my issue.

edit retag flag offensive close merge delete

Comments

Sage is written mostly in python, so I suspect if you can answer this question for an arbitrary python library, you can answer it for Sage. I mention this because there may be help elsewhere for the more general case.

niles gravatar imageniles ( 2014-09-12 15:59:51 +0100 )edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2014-09-12 22:15:27 +0100

updated 2014-09-12 22:15:49 +0100

The answer may depend on what you mean by "available". I think this gives a list of all classes in Sage's default namespace:

import inspect
[_ for _ in dir() if inspect.isclass(eval(_))]

To get a more complete list, I suppose you could replace dir() with dir(MODULE) and then iterate over all py and pyx files in Sage's library (as in dir(sage.algebras.steenrod.steenrod_algebra_misc)). To do this iteration, you might use os.path.walk. Once you've found a class, dir(CLASS) should give you its attributes and methods.

edit flag offensive delete link more
1

answered 2014-09-12 16:15:44 +0100

niles gravatar image

Each directory and subdirectory in the sage source has a file named all.py which lists all the class names that should be imported when one does from this.package import *. The top level one is here. This is a lot of stuff, but maybe not quite _every single_ class. Is that enough for what you want though?

Note: Getting all the classes seems like a good start, but I don't know how to get all the method names of a class -- python's dir does this for an _instance_ of a class, but that's not the same thing.

edit flag offensive delete link more
0

answered 2014-09-12 07:49:34 +0100

rws gravatar image

Maybe the reference index can help: http://sagemath.org/doc/reference/gen...

edit flag offensive delete link more

Comments

It is a bit messy to parse; it feels like it should be possible to do from within Sage. In Mathematica, it is quite easy to do this.

PerAlexandersson gravatar imagePerAlexandersson ( 2014-09-12 11:20:06 +0100 )edit

how is that list generated? presumably something that sphinx does . . .

niles gravatar imageniles ( 2014-09-12 16:21:27 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2014-09-11 21:04:58 +0100

Seen: 876 times

Last updated: Sep 12 '14