Ask Your Question
0

Clearing all user-defined variables from current session

asked 2012-12-20 10:10:01 -0600

Louisa Grey gravatar image

I'm using Sage from the interactive shell. How can I clear/remove all the variables I have defined so far in my current session?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
5

answered 2012-12-20 11:44:49 -0600

DSM gravatar image

You can use reset():

sage: a = 3
sage: a
3
sage: reset()
sage: a
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
[...]
NameError: name 'a' is not defined

You can also give variable names, like reset("a b c") and so on. Type reset? at the console for the details.

edit flag offensive delete link more

Comments

Doing this in Sage 7.6 gives:

sage: a=2; a
2
sage: reset()
sage: a
Traceback (most recent call last):
...
NameError: name 'a' is not defined
sage: quit
Traceback (most recent call last):
...
NameError: name 'quit' is not defined

This issue is considered in this ticket: reset does not restore "quit"

jipilab gravatar imagejipilab ( 2017-03-29 10:41:00 -0600 )edit

%reset -s looks like a potentially better way to do this.

John Palmieri gravatar imageJohn Palmieri ( 2017-03-30 12:47:47 -0600 )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

Stats

Asked: 2012-12-20 10:10:01 -0600

Seen: 2,684 times

Last updated: Dec 20 '12