How to understand '_' in these tests?

random832 at fastmail.us random832 at fastmail.us
Tue Jun 2 00:23:49 EDT 2015


On Tue, Jun 2, 2015, at 00:18, fl wrote:
> Hi,
> 
> I just know that '_' is the last result in the Python interpreter. I feel that
> it is like 'ans' in Matlab. When I run the following commands. The result of
> '_' are always '4'.
> 
> 
> Because I have tried several commands, such as reversed('fred'), xx and rx,
>  '4' are always there.
> 
> What is your explanation about the following?

The use of _ for the last result is a special feature of the REPL. It
does not work if there is a real variable called _.

Try del _ before trying to print _.



More information about the Python-list mailing list