This is by design. The intent is that as long as you call something that returns no value, your last result is not thrown away. IOW _ is the last result that wasn't None. Please don't change this. --Guido On 6/7/06, Raymond Hettinger <raymond.hettinger at verizon.net> wrote: > When the result of an expression is None, the interactive interpreter > correctly suppresses the display of the result. However, it also > suppresses the underscore assignment. I'm not sure if that is correct > or desirable because a subsequent statement has no way of knowing > whether the underscore assignment is current or whether it represents an > earlier non-None result. > > Here's an example from a co-worker's regular expression experiments: > > >>> import re, string > >>> re.search('lmnop', string.letters) > <_sre.SRE_Match object at 0xb6f2c480> > >>> re.search('pycon', string.letters) > >>> if _ is not None: > ... print _.group() > lmnop > > > > Raymond > > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org > -- --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4