what's the deal of "_" in Python?

P

phansen

Yun said:
Can someone give me some pointers to the related docs? Thanks.

It's a variable name. See http://docs.python.org/ref/identifiers.html

If you were hoping of a more elaborate answer, please refer to
http://groups.google.ca/[email protected]
and also give just a *little* more detail in your next question,
so we don't have to mindread about which use of "_" you are
talking about. It's used as a standalone variable name, as a
prefix in several different ways, sometimes as a substitute for
self, and so on. Which do you mean?

-Peter
 
E

Elaine Jackson

The python interpreter understands "_" as a reference to the last value it
computed, exactly analogous to "%" in the maple interpreter if you're familiar
with that. I think it's also used as a (loop-) variable name with the
implication that the variable will never be referenced. (Personally I like to
use the name "anonymous" for that purpose.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top