You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sage-cell
From the net I got that the result of the previous computation can be referred to as _. But if I try to use it in SageCell like in
1+2
_+5
I get an error. What is the correct way to refer to previous results?
Andrey Novoseltsev
unread,
Apr 11, 2017, 6:44:07 PM4/11/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sage-cell
I never used or saw _ used in SageMathCell. There is a question of what "previous computation" is. Since I am used to SageNB, for me previous computation is the result of the previous cell, which does not make much sense when there is only one cell ;-)
I don't think that SageMathCell has any special treatment for _ on its own, so if it does or does not work, it is due to Sage/IPython/Jupyter/etc handing actual code and output. So - if things worked before and got broken I'll try to fix them, but if they never worked I claim that it is by design and should not be impemented.
Rob Beezer
unread,
Apr 11, 2017, 6:53:48 PM4/11/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sage...@googlegroups.com
Maybe it is a *convention* that "_" is the previous result.
"_" is a legitimate variable name in Python, so it is sometimes used for results
you don't really intend to keep.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sage-cell, bee...@ups.edu
On Tuesday, 11 April 2017 16:53:48 UTC-6, Robert Beezer wrote:
Maybe it is a *convention* that "_" is the previous result.
"_" is a legitimate variable name in Python, so it is sometimes used for results
you don't really intend to keep.
The following produces 8 in the Sage Cell:
_ = 1 + 2
_ + 5
Rob
Well, it is a convention that _ is automatically assigned the last result and on Sage command line you can do
sage: 1 + 2 3 sage: _ + 5 8
My point was that there are two separate computations here, but when entered in a single cell these two lines make "one computation", so _ does not get any value (also 3 is not displayed since only the last result is shown).