Ipython: automatically echo the result of an assignment operation?

Is there a way to make iPython automatically repeat the result of an assignment operation?

For example, in MATLAB, the completion of an assignment operator without a semicolon displays the result of the assignment, and the semicolon at the end of the statement suppresses any output.

>> b=1+2 b = 3 >> b=1+2; >> 

I want to be able to do something similar in iPython. However, at present I have to use two separate operators if I want to see the result of the assignment:

 In [32]: b=1+2 In [33]: b Out[33]: 3 
+8
python ipython
source share
1 answer

An assignment is just an operator in Python, so you will need to compile the code, go through the AST, find the assignment, and then print the repr() variable after it runs.

0
source share

All Articles