# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1180496450 25200
# Node ID ab89e8f68b2419166ef6f6f28cde3d20b0cf9861
# Parent  360a98d2be44a672ee76ccccb28ac9052fe0e096
Add a command clear_vars() that deletes all global 1-letter predefined symbolic variables.

diff -r 360a98d2be44 -r ab89e8f68b24 sage/calculus/all.py
--- a/sage/calculus/all.py	Tue May 29 16:54:36 2007 -0700
+++ b/sage/calculus/all.py	Tue May 29 20:40:50 2007 -0700
@@ -22,7 +22,7 @@ from functional import (diff, derivative
                         integrate, limit, lim,
                         taylor, simplify)
 
-from var import (var, function)
+from var import (var, function, clear_vars)
 
 from predefined import (a,
                       b,
diff -r 360a98d2be44 -r ab89e8f68b24 sage/calculus/var.pyx
--- a/sage/calculus/var.pyx	Tue May 29 16:54:36 2007 -0700
+++ b/sage/calculus/var.pyx	Tue May 29 20:40:50 2007 -0700
@@ -109,3 +109,31 @@ def function(s, *args):
     return v
 
 
+def clear_vars():
+    """
+    Delete all 1-letter symbolic variables that are predefined at
+    startup of SAGE.  Any one-letter global variables that are not
+    symbolic variables are not cleared.
+
+    EXAMPLES:
+        sage: (x+y)^z
+        (y + x)^z
+        sage: k = 15
+        sage: clear_vars()
+        sage: (x+y)^z
+        Traceback (most recent call last):
+        ...
+        NameError: name 'x' is not defined
+        sage: expand((e + i)^2)
+        2*e*I + e^2 - 1
+        sage: k
+        15        
+    """
+    G = globals()
+    from sage.calculus.calculus import SymbolicVariable
+    for i in range(65,65+26) + range(97,97+26):
+        if G.has_key(chr(i)) and isinstance(G[chr(i)], SymbolicVariable):
+           del G[chr(i)]
+
+    
+    
