On 6/7/06, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> > for users, it's actually quite simple to figure out what's in the _
> > variable: it's the most recently *printed* result.  if you cannot see
> > it, it's not in there.
>
> Of course, there's a pattern to it.  The question is whether it is the *right*
> behavior.  Would the underscore assignment be more useful and intuitive
> if it always contained the immediately preceding result, even if it was None?
> In some cases (such as the regexp example), None is a valid and useful
> possible result of a computation and you may want to access that result with 
> _.

If you're using _ in an interactive environment, it's usually because
you don't want to re-type the value of the expression.  If the value
is None, it isn't hard to type.

> BTW, there is a trivial exception to the "most recently printed result" rule.
>
>     >>> 13
>     13
>     >>> _ = None
>     >>> _                   # _ is no longer the most recently printed result

If you want to assign to _, the results are your own fault.

Jeremy
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to