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

Markus Meskanen markusmeskanen at gmail.com
Thu Mar 30 05:59:57 EDT 2017


On Thu, Mar 30, 2017 at 12:53 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>
> 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.
>

I think "relatively rare" is rather subjective, it's surely not everyday
stuff but that doesn't mean it's not done often.
And instead of learning a special syntax, which is simple and easy to
understand when they google "repeat many times python", they now end up
learning a special semantic by naming the variable with an underscore. If
and when someone asks "how to repeat many times in Python", I'd rather
answer "use repeat_for X" instead of "use for _ in range(X)"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170330/92773cbf/attachment.html>


More information about the Python-ideas mailing list