[Poll] Private variables
Alex Martelli
aleax at aleax.it
Sun Sep 16 10:34:06 EDT 2001
Aahz Maruch wrote:
> In article <mailman.1000325655.6912.python-list at python.org>,
> Tim Peters <tim.one at home.com> wrote:
>>
>>They serve different purposes -- a single leading underscore is merely
>>advisory, while a private name is also merely advisory <wink> but
>>indicates you're more serious about it. Semantically, the single
>>leading underscore means nothing, so is purely convention.
>
> That's *almost* true. The convention comes from the fact that in a
> slightly different context, a single leading underscore *does* have
> meaning: module attributes with a single leading underscore do not get
> imported with "from foo import *". (Well, this was true until the
> __all__ attribute got created, but let's not quibble.)
Another marginal but interesting case is with the Bastion module. By
default, Bastion exposes the attributes of the object it's wrapping if and
only if their names do not start with underscores. While you can
explicitly program a different filter, of course, still this default
behavior would lead me to say of the leading-underscore-in-name that it
"means nothing... is purely convention" is somewhat of an underbid.
Alex
More information about the Python-list
mailing list