Sharedsupport / 2015-03-25-150736-globals.sagewsOpen in CoCalc
Authors: Harald Schilly, ℏal Snyder, William A. Stein
License: GNU General Public License v3.0
Description: Examples for support purposes.
%cython def f(): return globals()
Auto-generated code...  
g = f()
g.keys()
['f', '__builtins__', '__file__', '__package__', '__test__', '__name__', '__doc__']
var('a')
a
a
a
var??
File: /projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/.sagemathcloud/sage_salvus.py Source: def var(*args, **kwds): """ Create symbolic variables and inject them into the global namespace. NOTE: In SageCloud, you can use var as a line decorator:: %var x %var a,b,theta # separate with commas %var x y z t # separate with spaces Use latex_name to customizing how the variables is typeset: var1 = var('var1', latex_name=r'\sigma^2_1') show(e^(var1**2)) Multicolored variables made using the %var line decorator: %var(latex_name=r"\color{green}{\theta}") theta %var(latex_name=r"\color{red}{S_{u,i}}") sui show(expand((sui + x^3 + theta)^2)) Here is the docstring for var in Sage: """ if 'latex_name' in kwds: # wrap with braces -- sage should probably do this, but whatever. kwds['latex_name'] = '{%s}'%kwds['latex_name'] if len(args) > 0: return var0(*args, **kwds) else: def f(s): return var0(s, *args, **kwds) return f