Ask Your Question
3

How to get the list of user defined variables

asked 2013-02-01 18:32:41 +0200

Edinah gravatar image

updated 2013-02-01 21:24:06 +0200

kcrisman gravatar image

How do I get the list of user defined variables in a sage session I just loaded using the load_session command ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-02-05 02:03:39 +0200

benjaminfjones gravatar image

updated 2013-02-05 02:04:17 +0200

That's a good question. You can inspect the global variables that have been defined at any given point in a session, but most of those will be defined when various modules load on Sage startup. You can look just at those globals whose type is sage.symbolic.expression.Expression, there aren't too many at startup:

sage: G = globals()
sage: for k in G:
....:     if type(G[k]) == sage.symbolic.expression.Expression:
....:         print k
golden_ratio
log2
NaN
merten
I
twinprime
pi
catalan
brun
euler_gamma
x
khinchin
i
glaisher
mertens

Anything not on that list is a global symbolic expression that is defined in your loaded session. Variables will be among these.

edit flag offensive delete link more

Comments

Thank you very much!

Edinah gravatar imageEdinah ( 2013-02-05 12:20:48 +0200 )edit
0

answered 2016-01-28 14:29:29 +0200

stan gravatar image

There is another way, taken from a different post:

sage: show_identifiers()

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2013-02-01 18:32:41 +0200

Seen: 1,317 times

Last updated: Jan 28 '16