On Mon, 19 Apr 2010 13:09:34 +0200, bb <bblo...@arcor.de> wrote:
> Tnx!
> 
> Is there any explanation why the magic ends with del ?
> 
> sage: del x
> sage: x
> ---------------------------------------------------------------------------
> NameError                                 Traceback (most recent call last)
> 
> /home/bb/sage-4.3.5/local/lib/python2.6/site-packages/sage/all_cmdline.pyc 
> in <module>()
> 
> NameError: name 'x' is not defined
> sage:
> 
> 
> So the feature theses fits like a glove?

A very popular feature is introspection.  In this particular case, doing

sage: reset?

would tell you what reset does:

"Delete all user defined variables, reset all globals variables back to
their default state, and reset all interfaces to other computer algebra
systems."

The feature that Harald was referring to is that x is a predefined
global variable.  You know this by doing

sage: globals()['x']
x

So now we know what the Sage function "reset" does.  "del", on the other
hand, is a Python builtin function.  Googling "del python" gives that
"del can also be used to delete entire variables".

So "del x" deletes the global variable from globals():

sage: del x
sage: globals()['x']
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)

/home/ghitza/<ipython console> in <module>()

KeyError: 'x'


But if you reset again, x is back:

sage: reset
sage: globals()['x']
x


And everything is behaving exactly as the docstrings indicate.


Alex


-- 
Alex Ghitza -- http://aghitza.org/
Lecturer in Mathematics -- The University of Melbourne -- Australia

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to