On 30 March 2017 at 19:18, Markus Meskanen <markusmeska...@gmail.com> wrote:
> Hi Pythonistas,
>
> yet again today I ended up writing:
>
> d = [[0] * 5 for _ in range(10)]
>
> And wondered, why don't we have a way to repeat other than looping over
> range() and using a dummy variable?

Because it's relatively rare to not use the loop variable for anything
(even if it's just a debug message), and in the cases where you
genuinely don't use it, a standard idiom can be applied (using a
single or double underscore as a dummy variable), rather than all
future users of the language needing to learn a special case syntax.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to