Does anyone else use this little idiom?

Bob Martin bob.martin at excite.com
Mon Feb 4 10:08:44 EST 2008


in 332496 20080204 102153 "=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=" <bjourne at gmail.com> wrote:
>> 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)

Rexx's method is the way to do it : "do 50"



More information about the Python-list mailing list