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

Discussion in 'Python' started by Yun Mao, Sep 16, 2004.

  1. Yun Mao

    Yun Mao Guest

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

    -Yun
     
    Yun Mao, Sep 16, 2004
    #1
    1. Advertising

  2. Yun Mao

    phansen Guest

    Yun Mao wrote:
    > 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/groups?threadm=
    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
     
    phansen, Sep 16, 2004
    #2
    1. Advertising

  3. Yun Mao

    Erik Heneryd Guest

    Erik Heneryd, Sep 16, 2004
    #3
  4. 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.)
     
    Elaine Jackson, Sep 17, 2004
    #4
  5. Alex Martelli, Sep 17, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rbt

    deal or no deal

    rbt, Dec 22, 2005, in forum: Python
    Replies:
    7
    Views:
    587
    Duncan Smith
    Dec 28, 2005
  2. John Salerno
    Replies:
    3
    Views:
    250
    Terry Reedy
    Jun 14, 2008
  3. r2d3
    Replies:
    1
    Views:
    1,437
  4. Replies:
    10
    Views:
    858
    Miki Tebeka
    Sep 28, 2012
  5. Dave Angel
    Replies:
    0
    Views:
    200
    Dave Angel
    Jul 24, 2012
Loading...

Share This Page