# Desattribution of a value to a variable

Suppose I have attributed to `a`

the value 3. But for the following operation I want to use anew `a`

as a variable how should I operate, redefine `a`

?

Desattribution of a value to a variable

`a`

the value 3. But for the following operation I want to use anew `a`

as a variable how should I operate, redefine `a`

?

add a comment

1

A Python name is just a pointer to a Python/Sage object:

```
sage: a = 3
sage: a+a
6
```

Now, if you redefine it, it will just point to the new object:

```
sage: a = 12
sage: a
12
sage: a^2
144
```

If you want the symbol `a`

(not to be confused with the Python name `a`

), you can do:

```
sage: SR.var('a')
a
```

Any Python name can point to such symbol:

```
sage: b = SR.var('a')
sage: b
a
sage: (b+1)^2
(a + 1)^2
```

What confuses most people is that the shortcut:

```
sage: var('a')
a
```

both returns the symbol `a`

and let the Python name `a`

point to this symbol, in particular, it removes the previous pointer of the Python name `a`

:

```
sage: a # this a is a Python name
a # this a is a symbol, pointed bythe previous Python name
```

Please start posting anonymously - your entry will be published after you log in or create a new account.

Asked: ** 2020-05-12 16:53:36 +0200 **

Seen: **76 times**

Last updated: **May 12 '20**

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.