Ask Your Question
0

Protect built-in variables?

asked 2015-06-04 05:26:27 +0200

Oderyn gravatar image

updated 2015-06-04 07:57:56 +0200

rws gravatar image

Is there a way to protect built-in variables? This means that I get a warning if I use code like this:

pi = 5
var('I')
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-06-04 07:36:18 +0200

rws gravatar image

updated 2015-06-04 07:56:58 +0200

If you ever lose a constant, bring it back via their absolute references:

sage: pi = 3
sage: pi = sage.symbolic.constants.pi
sage: pi.n()
3.14159265358979
sage: sage.symbolic.constants.[TAB]
sage.symbolic.constants.Catalan
sage.symbolic.constants.Constant
sage.symbolic.constants.E
sage.symbolic.constants.EulerGamma
sage.symbolic.constants.Glaisher
sage.symbolic.constants.GoldenRatio
sage.symbolic.constants.I
sage.symbolic.constants.Khinchin
sage.symbolic.constants.Log2
sage.symbolic.constants.Mertens
sage.symbolic.constants.NaN
sage.symbolic.constants.NotANumber
sage.symbolic.constants.Pi
sage.symbolic.constants.TwinPrime
sage.symbolic.constants.catalan
sage.symbolic.constants.constants_name_table
sage.symbolic.constants.constants_table
sage.symbolic.constants.e
sage.symbolic.constants.euler_gamma
sage.symbolic.constants.glaisher
sage.symbolic.constants.golden_ratio
sage.symbolic.constants.infinity
sage.symbolic.constants.khinchin
sage.symbolic.constants.log2
sage.symbolic.constants.math
sage.symbolic.constants.mertens
sage.symbolic.constants.minus_infinity
sage.symbolic.constants.partial
sage.symbolic.constants.pi
sage.symbolic.constants.sage
sage.symbolic.constants.twinprime
sage.symbolic.constants.unpickle_Constant
sage.symbolic.constants.unsigned_infinity
edit flag offensive delete link more

Comments

1

Where is the lower case i..? Anyway, I know how to get them back (one can also use restore). It's just that I want to avoid strange bugs which can happen if I set the value of a built-in variable.

Oderyn gravatar imageOderyn ( 2015-06-04 09:44:13 +0200 )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

1 follower

Stats

Asked: 2015-06-04 05:26:27 +0200

Seen: 71 times

Last updated: Jun 04 '15