On Tue, Jun 16, 2009 at 9:12 PM, Utpal Sarkar<doe...@gmail.com> 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: d > 0 > sage: f() > sage: d > d > (I put the d = 1 in the function definition to show the difference in > behaviour)
Use new_var: sage: d=0 sage: def foo(n): ... d = sage.calculus.var.new_var('d') ... print d^n ... ... sage: foo(10) d^10 sage: d 0 Maybe var(global=False) should be an option? William --~--~---------~--~----~------------~-------~--~----~ 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 URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---