what's the deal of "_" in Python?
john at grulic.org.ar
Fri Sep 17 05:33:43 CEST 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...
Size: 196 bytes
Desc: Digital signature
More information about the Python-list