[Python-ideas] Way to repeat other than "for _ in range(x)"

Markus Meskanen markusmeskanen at gmail.com
Thu Mar 30 11:08:31 EDT 2017


Just an example among many :)

On Mar 30, 2017 6:07 PM, "Kyle Lahnakoski" <klahnakoski at mozilla.com> wrote:

>
>
> On 2017-03-30 05:18, Markus Meskanen wrote:
> > Hi Pythonistas,
> >
> > yet again today I ended up writing:
> >
> > d = [[0] * 5 for _ in range(10)]
> >
> >
> > Thoughts?
>
> It looks like you are initializing matrices.  Can you make a helper
> function?
>
> d = matrix(shape=(5, 10), default=0)
>
> or maybe use NumPy?
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170330/f2b67ae6/attachment-0001.html>


More information about the Python-ideas mailing list