On Thursday 30 March 2017 02:48 PM, Markus Meskanen 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? This seems like a rather common
thing to do, and while the benefit doesn't seem much, something like
this would be much prettier and more pythonic than using underscore
variable:
d = [[0] * 5 repeat_for 10]
Why not:
d = [[0] * 5 ] * 10
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/