[Sugar-devel] Correct use of leading underscores in Python?
Jim Simmons
nicestep at gmail.com
Mon Jul 20 11:59:05 EDT 2009
I don't want to start a religious war here, but I could use some
guidance. In writing my Activities I have often copied and pasted
bits of code from other Activities. For instance, the toolbars from
Read and Speak. As a result of this I have code in which leading
underscores are used in both variable names and method names, with no
particular rhyme or reason for it. I want my code to follow good
practices, but the only thing I've found which talks about leading
underscores in Python is the PEP 8 style guide, which says:
"In addition, the following special forms using leading or trailing
underscores are recognized (these can generally be combined with any
case convention):
- _single_leading_underscore: weak "internal use" indicator. E.g.
"from M import *" does not import objects whose name starts with an
underscore."
and also
"Use one leading underscore only for non-public methods and instance variables."
None of the leading underscores in my code seem to be for these reasons.
So when do you use leading underscores to name something? Or do you
ever use them?
Thanks,
James Simmons
More information about the Sugar-devel
mailing list