How do I retrieve the output of a previous command and save it in a variable inside the Python interactive shell? -
say ran expensive operation foo() returns me large list, forgot save output of foo() inside variable.
let's assume if run foo() again, different output.
but need output first time ran foo().
in effect, asking if there buffer stores output of last command, read?
_ (single underscore) works me in python 3 windows, should work other versions well:
>>> 1 + 1 2 >>> x = _ >>> x 2
Comments
Post a Comment