Ask Your Question
0

List all available classes and functions

asked 2014-09-11 14:04:58 -0500

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 08:59:51 -0500 )edit

3 answers

Sort by ยป oldest newest most voted
1

answered 2014-09-12 15:15:27 -0500

updated 2014-09-12 15:15:49 -0500

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 09:15:44 -0500

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 00:49:34 -0500

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 04:20:06 -0500 )edit

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

niles gravatar imageniles ( 2014-09-12 09:21:27 -0500 )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 14:04:58 -0500

Seen: 135 times

Last updated: Sep 12 '14