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

Peng Yu pengyu.ut at gmail.com
Wed Nov 18 22:03:02 EST 2009


On Wed, Nov 18, 2009 at 8:50 PM, Benjamin Kaplan
<benjamin.kaplan at case.edu> wrote:
> 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.

I knew this. That's why I put quote around 'private' in the email subject.



More information about the Python-list mailing list