osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to understand '_' in these tests?


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?


Thanks,






>>> reversed('fred')
<reversed object at 0x02A8DD50>
>>> _
'4'
>>> _
'4'
>>> xx
33223
>>> _
'4'
>>> rx=reversed('fred')
>>> _
'4'
>>> xx
33223
>>> _
'4'
>>>