What are the naming convention for private member variable, andprivate and public member function?

Discussion in 'Python' started by Peng Yu, Sep 20, 2009.

  1. Peng Yu

    Peng Yu Guest

    Hi,

    It says in http://www.python.org/dev/peps/pep-0008/

    " Method Names and Instance Variables

    Use the function naming rules: lowercase with words separated by
    underscores as necessary to improve readability.

    Use one leading underscore only for non-public methods and
    instance
    variables."

    I am wondering what is the different between member function and
    member variable in term of naming convention.

    Regards,
    Peng
     
    Peng Yu, Sep 20, 2009
    #1
    1. Advertising

  2. > It says in http://www.python.org/dev/peps/pep-0008/
    >
    > " Method Names and Instance Variables
    >
    > Use the function naming rules: lowercase with words separated by
    > underscores as necessary to improve readability.
    >
    > Use one leading underscore only for non-public methods and
    > instance
    > variables."
    >
    > I am wondering what is the different between member function and
    > member variable in term of naming convention.


    Nothing that I know of. If they are "private" they should both start
    with an underscore, if they are "public" they should not.

    HTH,
    Daniel



    --
    Psss, psss, put it down! - http://www.cafepress.com/putitdown
     
    Daniel Fetchinson, Sep 20, 2009
    #2
    1. Advertising

  3. Peng Yu

    Dave Angel Guest

    Peng Yu wrote:
    > Hi,
    >
    > It says in http://www.python.org/dev/peps/pep-0008/
    >
    > " Method Names and Instance Variables
    >
    > Use the function naming rules: lowercase with words separated by
    > underscores as necessary to improve readability.
    >
    > Use one leading underscore only for non-public methods and
    > instance
    > variables."
    >
    > I am wondering what is the different between member function and
    > member variable in term of naming convention.
    >
    > Regards,
    > Peng
    >
    >

    Member functions are verbs or sometimes adjectives, while member
    variables are nouns.

    DaveA
     
    Dave Angel, Sep 20, 2009
    #3
  4. Peng Yu

    Simon Forman Guest

    On Sep 19, 11:33 pm, Peng Yu <> wrote:
    > Hi,
    >
    > It says inhttp://www.python.org/dev/peps/pep-0008/
    >
    > "    Method Names and Instance Variables
    >
    >       Use the function naming rules: lowercase with words separated by
    >       underscores as necessary to improve readability.
    >
    >       Use one leading underscore only for non-public methods and
    > instance
    >       variables."
    >
    > I am wondering what is the different between member function and
    > member variable in term of naming convention.
    >
    > Regards,
    > Peng


    The naming convention for both to indicate that attributes of a class
    should be considered internal is a leading underscore.
     
    Simon Forman, Sep 21, 2009
    #4
    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. DaveLessnau
    Replies:
    3
    Views:
    451
    Howard
    May 16, 2005
  2. Peng Yu
    Replies:
    0
    Views:
    313
    Peng Yu
    Nov 19, 2009
  3. Chris Rebert
    Replies:
    2
    Views:
    382
    Gregory Ewing
    Nov 21, 2009
  4. Peng Yu
    Replies:
    1
    Views:
    353
    Lie Ryan
    Nov 22, 2009
  5. Marco
    Replies:
    37
    Views:
    2,182
    Jorgen Grahn
    Jan 5, 2011
Loading...

Share This Page