Convention for name indicating "don't care about the value" (was: Is using range() in for loops really Pythonic?)
Ben Finney
bignose+hates-spam at benfinney.id.au
Sun May 11 23:41:25 EDT 2008
Carl Banks <pavlovevidence at gmail.com> writes:
> On May 11, 6:44 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
> wrote:
> > In such cases, the name 'dummy' is conventionally bound to the items
> > from the iterator, for clarity of purpose::
> >
> > for dummy in range(10):
> > # do stuff that makes no reference to 'dummy'
>
> Is this documented?
It's not a documented standard, to my knowledge.
> I've never heard of this convention. It's not PEP 8, and I've never
> seen consistent usage of any name. I'd be interested in knowing
> where you read that this was a convention, or in what subcommunities
> it's a convention in.
It has been in this forum that the use of the name '_' for "don't care
about the value" was deprecated, since that name is already overloaded
with other meanings.
> I think dummy is a terrible name to use for this, since in no other
> usage I can think of does the word "dummy" suggest something isn't
> used.
I think it's far superior to '_'. I'd be just as happy with any other
name that explicitly distinguishes itself for this purpose.
> If a value isn't used, then I think the most clear name for it is
> "unused".
Sounds good to me. Now we merely need to convince the world.
--
\ “Software patents provide one more means of controlling access |
`\ to information. They are the tool of choice for the internet |
_o__) highwayman.” —Anthony Taylor |
Ben Finney
More information about the Python-list
mailing list