Does anyone else use this little idiom?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Feb 3 00:49:49 EST 2008


On Sat, 02 Feb 2008 18:03:54 -0800, miller.paul.w wrote:

> for _ in xrange (1,n):
>    some code
... 
> So, I guess I'm wondering if anyone else uses a similar idiom and if
> there are any downsides to it that I'm not aware of.

Sometimes, but not often.

If I'm writing a use-once-then-throw-away script, it's too much trouble 
to press the Shift key to get an underscore *wink*, so I tend to just use 
i or x for the loop variable.

If I'm writing something I intend to keep, but don't care too much about, 
I'll use _, i or x about equal numbers of times, depending on whim.

If I was writing something important I expected others to read, I'd use 
dummy.

I wouldn't go so far as to say "Don't use that idiom!", but it's not 
something I use often.


-- 
Steven



More information about the Python-list mailing list