MRAB
1/10/2008 1:34:00 AM
On Jan 9, 11:17 pm, Ben Finney <bignose+hates-s...@benfinney.id.au>
wrote:
> "Diez B. Roggisch" <de...@nospam.web.de> writes:
>
> > The underscore is used as "discarded" identifier. So maybe
>
> > for _ in xrange(10):
> > ...
>
> The problem with the '_' name is that it is already well-known and
> long-used existing convention for an entirely unrelated purpose: in
> the 'gettext' i18n library, the '_' function to get the
> locally-translated version of a text string.
>
> Since the number of programs that need to use something like 'gettext'
> (and therefore use the '_' function) is likely only to increase, it
> seems foolish to set one's program up for a conflict with that
> established usage.
>
> I've seen 'dummy' used as a "don't care about this value" name in
> other Python code. That seems more readable, more explicit, and less
> likely to conflict with existing conventions.
>
Perhaps a "discarded" identifier should be any which is an underscore
followed by digits.
A single leading underscore is already used for "private" identifiers,
but they are usually an underscore followed by what would be a valid
identifier by itself, eg. "_exit".
The convention would then be:
2 underscores + valid_by_self + 2 underscores => special
underscore + valid_by_self => private
underscore + invalid_by_self => dummy