[sage-support] Re: bug: no local scope for symbolic variables

2009-06-18 Thread Ondrej Certik
On Thu, Jun 18, 2009 at 12:29 AM, Robert Bradshaw wrote: > > On Jun 17, 2009, at 9:21 AM, William Stein wrote: > >> 2009/6/17 Robert Bradshaw : >>> >>> On Jun 17, 2009, at 3:05 AM, Utpal Sarkar wrote: >>> Thanks for the replies. I noticed something funny: if you call x = var("X") in some

[sage-support] Re: bug: no local scope for symbolic variables

2009-06-17 Thread Robert Bradshaw
On Jun 17, 2009, at 9:21 AM, William Stein wrote: > 2009/6/17 Robert Bradshaw : >> >> On Jun 17, 2009, at 3:05 AM, Utpal Sarkar wrote: >> >>> Thanks for the replies. >>> I noticed something funny: if you call x = var("X") in some >>> scope, it >>> is X that is injected into the global scope, no

[sage-support] Re: bug: no local scope for symbolic variables

2009-06-17 Thread Martin Rubey
William Stein writes: > 3. Having var at all is a compromise -- many symbolic calculus users > would prefer for undefined vars to just "magically" be defined, as is > done in Mathematica, Maple, Maxima, Axiom (?), etc. In Axiom (FriCAS, OpenAxiom), there is a distinction between elements of, sa

[sage-support] Re: bug: no local scope for symbolic variables

2009-06-17 Thread William Stein
2009/6/17 Robert Bradshaw : > > On Jun 17, 2009, at 3:05 AM, Utpal Sarkar wrote: > >> Thanks for the replies. >> I noticed something funny: if you call x = var("X") in some scope, it >> is X that is injected into the global scope, not x. In fact I thought >> that the argument was merely a print na

[sage-support] Re: bug: no local scope for symbolic variables

2009-06-17 Thread Robert Bradshaw
On Jun 17, 2009, at 3:05 AM, Utpal Sarkar wrote: > Thanks for the replies. > I noticed something funny: if you call x = var("X") in some scope, it > is X that is injected into the global scope, not x. In fact I thought > that the argument was merely a print name. var("X") is what makes the varia

[sage-support] Re: bug: no local scope for symbolic variables

2009-06-17 Thread Utpal Sarkar
Thanks for the replies. I noticed something funny: if you call x = var("X") in some scope, it is X that is injected into the global scope, not x. In fact I thought that the argument was merely a print name. On Jun 17, 1:49 am, Dan Drake wrote: > I ran into the problem discussed in this thread j

[sage-support] Re: bug: no local scope for symbolic variables

2009-06-16 Thread Dan Drake
I ran into the problem discussed in this thread just the other day, and my solution was to use sage.symbolic.ring. How does this solution compare to the others posted in this thread? Here's (basically) what I did: from sage.symbolic.ring import var as symbvar def foo(n, k): t = sy

[sage-support] Re: bug: no local scope for symbolic variables

2009-06-16 Thread Mike Hansen
On Tue, Jun 16, 2009 at 3:55 PM, Utpal Sarkar wrote: > > I think global=False would be a nice option, also because there seem > to be more differences between a symbolic variable created using "var" > and "new_var" than just the scope; I noticed that while "var" creates > a symbolic variable, "new

[sage-support] Re: bug: no local scope for symbolic variables

2009-06-16 Thread Utpal Sarkar
I think global=False would be a nice option, also because there seem to be more differences between a symbolic variable created using "var" and "new_var" than just the scope; I noticed that while "var" creates a symbolic variable, "new_var" creates an expression (class 'sage.symbolic.expression.Ex

[sage-support] Re: bug: no local scope for symbolic variables

2009-06-16 Thread Utpal Sarkar
Thanks! On Jun 16, 9:30 pm, William Stein wrote: > On Tue, Jun 16, 2009 at 9:12 PM, Utpal Sarkar wrote: > > > Hi, > > > It looks like locally defined symbolic variables are always global, in > > particular they overwrite globally defined variables of the same name: > > sage: d = 0 > > sage: def

[sage-support] Re: bug: no local scope for symbolic variables

2009-06-16 Thread William Stein
On Tue, Jun 16, 2009 at 9:12 PM, Utpal Sarkar wrote: > > Hi, > > It looks like locally defined symbolic variables are always global, in > particular they overwrite globally defined variables of the same name: > sage: d = 0 > sage: def f(): > :     d = var('d') > :     d = 1 > : > sage: