How to retrieve the output of the previous command and save it in the variable in the Python interactive shell?

Suppose I run an expensive operation foo(), which returns a large list, but I forgot to save the output of foo() in a variable.

Assuming I run foo() again, I will get a different output.

But the first time I run foo() I do need the output.

Actually Above, I asked if there are some buffers that store the output of the last command that I can read?

_ (single underscore) applies to my python 3 for windows, and also applies to other versions:

>>> 1 + 1
2
>>> x = _
>>> x
2

Suppose I run an expensive operation foo(), which returns a large list, but I forgot to save the output of foo() in a variable.

Assuming I run foo() again, I will get a different output.

But the first time I run foo() I do need the output.

Actually, I asked if there are some buffers that store the output of the last command that I can read?

_(single underscore) applies to my python 3 for windows, and also applies to other versions:

>>> 1 + 1
2
>>> x = _
>>> x
2

Leave a Comment

Your email address will not be published.