No. You can try
def f():
var('whatever')
f()
print whatever
Nothing to do with the fact that 't' was globally available before.
By design the function var:
- creates a new symbolic variable (*not* a Python variable)
- makes it available in the global namespace as a Python variable
Thanks
I guess I don't understand the difference between a python variable and a
symbolic variable.
I know that var is part of Sage but not defined in python.
I also know that the variables created inside a sage procedure using SR.var
are local, but ones created by var are not.
So inside of
Thanks
I guess I don't understand the difference between a python variable and a
symbolic variable.
I know that var is part of Sage but not defined in python.
I also know that the variables created inside a sage procedure using SR.var
are local, but ones created by var are not.
So inside of
To avoid confusion use "symbol" instead of "symbolic variable". A Python
variable is a variable in the sense of programming
https://en.wikipedia.org/wiki/Variable_%28computer_science%29
A symbol represents a mathematical variable as in
https://en.wikipedia.org/wiki/Variable_%28mathematics%29
On 2015-12-22 01:11, Carl Eberhart wrote:
Thanks
I guess I don't understand the difference between a python variable and
a symbolic variable.
A symbolic variable is a symbol or letter in the mathematical sense. It
is like the "x" appearing in mathematical formulas like
sin(x)^2 + cos(x)^2 ==
On 2015-12-21 16:38, Carl Eberhart wrote:
I admit I don't understand what is happening in the following snippit:
def f():
t=var('t')
t=5
a=2*t
return a
Solution: never use var() in a function. If you do need a symbolic
variable in a function (note that you don't in the
On Monday, December 21, 2015, Carl Eberhart wrote:
> I admit I don't understand what is happening in the following snippit:
>
> def f():
> t=var('t')
> t=5
> a=2*t
> return a
> t=3;t;f();t
> 3
> 10
> t
>
> This was executed in a sagews cell
> I think that
I admit I don't understand what is happening in the following snippit:
def f():
t=var('t')
t=5
a=2*t
return a
t=3;t;f();t
3
10
t
This was executed in a sagews cell
I think that the t which is referenced in f should be a local variable.
However the value of t outside of f is
Ah. Thanks very much for that clarification.
Actually, my snippet illustrates the dilemma I was in.
t already has a value outside of f
executing f changes the value of t outside of f
that is what I would expect to happen if t were declared global in f, but I
thought t was local in f
I still love
sage: x = this is x
sage: y = this is y
sage: z = this is z
sage: def f():
: print x
: y = new value
: print y
: global z
: z = new value
: print z
:
sage: f()
this is x
new value
new value
sage: x, y, z
('this is x', 'this is
On Thu, Sep 30, 2010 at 3:07 AM, Walker ebwal...@gmail.com wrote:
sage: x = this is x
sage: y = this is y
sage: z = this is z
sage: def f():
: print x
: y = new value
: print y
: global z
: z = new value
: print z
:
sage: f()
this
Hi Walker!
On 29 Sep., 16:42, Walker ebwal...@gmail.com wrote:
... My question is: is there a way to make Sage not
creating a global variable but assigning directly the global one?
This is actually a Python question. It would of course be very
dangerous if variables defined outside a function
It seems it has solved my issue, many thanks all of you; I'll attach a
snipped of code next time.
I knew Sage is based on Pyton, but what I don't know is where the
first ends and the second begins, so I usually think my issue is a
Sage's one...
Anyway, thank you: it was helpful.
--
To post to
On Wed, Sep 29, 2010 at 8:18 AM, Simon King simon.k...@nuigalway.ie wrote:
Hi Walker!
On 29 Sep., 16:42, Walker ebwal...@gmail.com wrote:
... My question is: is there a way to make Sage not
creating a global variable but assigning directly the global one?
This is actually a Python question.
14 matches
Mail list logo