# 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 ?

How to get the list of user defined variables

add a comment

2

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.

0

There is another way, taken from a different post:

sage: show_identifiers()

Asked: **
2013-02-01 11:32:41 -0500
**

Seen: **885 times**

Last updated: **Jan 28 '16**

Sage showed "TypeError: need a summation variable" when i used sum function with for loop

Why does list(primes(2,10)) behave different from [2,3,5,7]?

Generate a Matrix over a Finite Field with symbolic variables

Transferring variables between worksheets?

How to return a list from callable symbolic expression

How to get a list of the combinations such that the elements are equal to some $n$

frequency (count) in Numpy Array

If I return a list from a function that is more than 26 elements, the list goes vertical

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.