1 | initial version |
You can use
[k for k,v in list(globals().iteritems()) if isinstance(v,sage.symbolic.expression.Expression)]
to display all the names in the global namespace to which a symbolic expression is bound and
[k for k,v in list(globals().iteritems()) if isinstance(v,sage.symbolic.function.Function)]
to find all the names to which a symbolic function is bound. You can vary the query as desired.
You can of course look at globals().keys()
directly, but you'll probably find that's a bit unwieldy (and it is what vars()
ends up doing too (and as far as I can see it works as documented).
While it may seem at first that inspecting globals()
gives you a lot of information about the system, it's in practice rarely useful. Whether something is bound to a global name ends up being not so important in Python.