ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 28 Jan 2016 14:29:29 +0100How to get the list of user defined variableshttps://ask.sagemath.org/question/9763/how-to-get-the-list-of-user-defined-variables/How do I get the list of user defined variables in a sage session I just loaded using the load_session command ?Fri, 01 Feb 2013 18:32:41 +0100https://ask.sagemath.org/question/9763/how-to-get-the-list-of-user-defined-variables/Answer by stan for <p>How do I get the list of user defined variables in a sage session I just loaded using the load_session command ?</p>
https://ask.sagemath.org/question/9763/how-to-get-the-list-of-user-defined-variables/?answer=32353#post-id-32353There is another way, taken from a different post:
> sage: show_identifiers() Thu, 28 Jan 2016 14:29:29 +0100https://ask.sagemath.org/question/9763/how-to-get-the-list-of-user-defined-variables/?answer=32353#post-id-32353Answer by benjaminfjones for <p>How do I get the list of user defined variables in a sage session I just loaded using the load_session command ?</p>
https://ask.sagemath.org/question/9763/how-to-get-the-list-of-user-defined-variables/?answer=14506#post-id-14506That'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.Tue, 05 Feb 2013 02:03:39 +0100https://ask.sagemath.org/question/9763/how-to-get-the-list-of-user-defined-variables/?answer=14506#post-id-14506Comment by Edinah for <p>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 <code>sage.symbolic.expression.Expression</code>, there aren't too many at startup:</p>
<pre><code>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
</code></pre>
<p>Anything not on that list is a global symbolic expression that is defined in your loaded session. Variables will be among these.</p>
https://ask.sagemath.org/question/9763/how-to-get-the-list-of-user-defined-variables/?comment=18305#post-id-18305Thank you very much!Tue, 05 Feb 2013 12:20:48 +0100https://ask.sagemath.org/question/9763/how-to-get-the-list-of-user-defined-variables/?comment=18305#post-id-18305