You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was working on a little program in the IPython shell (invoked like ipython3 -i example.py) and got stumped for a while when a variable named _3 defined in example.py produced unexpected behaviour, but not immediately.
It took a while before I noticed that this problem didn't occur in the regular python shell, and even then the penny didn't drop immediately, because I wasn't yet familiar with the _n automatic variables for the output cache – I freely admit I'm still something of an IPython newbie.
Possible suggestions to prevent this kind of surprise:
present the user with a warning when assigning to a variable that may be silently overwritten in the future
or even an info or debug notice instead of a warning (e.g. when the user passes the --debug command-line flag to ipython)
or perhaps present this warning at the point that a previously assigned variable gets overwritten
or more fancily: make it configurable whether automatic variables are used at all (for the case of _3, setting --cache-size=0 would have worked, but this still doesn't prevent the likes of _i3 getting overwritten)
or yet more fancily: make it configurable whether automatic variables are allowed to overwrite previously set values
Finally, I suggest mentioning _4 in the %quickref, like _i4 already is. It's a strange omission at this point. For symmetry,
_oh : Output history
could be replaced by
_4, _oh[2:5] : Output history line 4, lines 2-4
The text was updated successfully, but these errors were encountered:
I was working on a little program in the IPython shell (invoked like
ipython3 -i example.py
) and got stumped for a while when a variable named_3
defined inexample.py
produced unexpected behaviour, but not immediately.It took a while before I noticed that this problem didn't occur in the regular python shell, and even then the penny didn't drop immediately, because I wasn't yet familiar with the
_n
automatic variables for the output cache – I freely admit I'm still something of an IPython newbie.Possible suggestions to prevent this kind of surprise:
--debug
command-line flag toipython
)_3
, setting--cache-size=0
would have worked, but this still doesn't prevent the likes of_i3
getting overwritten)Finally, I suggest mentioning
_4
in the%quickref
, like_i4
already is. It's a strange omission at this point. For symmetry,could be replaced by
The text was updated successfully, but these errors were encountered: