[Python-ideas] Way to repeat other than "for _ in range(x)"
Brice PARENT
contact at brice.xyz
Thu Mar 30 13:23:45 EDT 2017
Le 30/03/17 à 19:06, Markus Meskanen a écrit :
> And like I said before, for loop is just another way of doing while
> loop, yet nobody's complaining. There's nothing wrong with having two
> different ways of doing the same thing, as long as one of them is
> never the better way. If we add `repeat`, there's never a reason to
> use `for _ in range` anymore.
It doesn't always creates something easier to use, like for example :
`for _ in range(x, y, z)` (fixed or variable parameters)
`for _ in one_list` (saves a call to len() with your solution)
`for _ in any_other_kind_of_iterable` (we don't need to know the length
here, we may even use a generator)
More information about the Python-ideas
mailing list