What is the naming convention for accessor of a 'private' variable?

Benjamin Kaplan benjamin.kaplan at case.edu
Wed Nov 18 21:50:14 EST 2009


On Wed, Nov 18, 2009 at 9:27 PM, Peng Yu <pengyu.ut at gmail.com> wrote:
> http://www.python.org/dev/peps/pep-0008/
>
> The above webpage states the following naming convention. Such a
> variable can be an internal variable in a class. I'm wondering what is
> the naming convention for the method that access such variable.
>
>    - _single_leading_underscore: weak "internal use" indicator.  E.g. "from M
>      import *" does not import objects whose name starts with an underscore.
> --

You never have any convention for a method that accesses the private
variable. In a language that has scope declarations, a method that
uses private variables is still declared public or private- there's no
special keyword for it.

> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list