Does anyone else use this little idiom?
BJörn Lindqvist
bjourne at gmail.com
Mon Feb 4 05:21:53 EST 2008
> In Python, the direct translation of this is a for loop. When the
> index doesn't matter to me, I tend to write it as:
>
> for _ in xrange (1,n):
> some code
>
> An alternative way of indicating that you don't care about the loop
> index would be
>
> for dummy in xrange (1,n):
> some code
I usually use _ when I know that i18n doesn't matter. dummy is just to
long when unpacking sequences:
for dummy, email, dummy, dummy in persons:
sendmail(email)
for _, email, _, _ in persons:
sendmail(email)
--
mvh Björn
More information about the Python-list
mailing list