what's the deal of "_" in Python?
John Lenton
john at grulic.org.ar
Thu Sep 16 23:33:43 EDT 2004
On Thu, Sep 16, 2004 at 06:15:11PM -0400, Yun Mao wrote:
> Can someone give me some pointers to the related docs? Thanks.
in the interactive interpreter, _ is the value of the last
expression. In some code I've seen it used as a dummy variable inside
'tight' loops (map(lambda_: _.bar(), foo)), but that use is
diminishing (due mostly to list comprehensions, I guess). In
internationalized code it is usually used as
from gettext import gettext as _
or something similar. This last use is arguably ugly, but it is a
time-honored convention dating back to the cambric days, when people
programmed end-user programs in C.
--
John Lenton (john at grulic.org.ar) -- Random fortune:
For large values of one, one equals two, for small values of two.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20040917/ba297d86/attachment.sig>
More information about the Python-list
mailing list