[Python-ideas] Simpler syntax for basic iterations
Terry Reedy
tjreedy at udel.edu
Wed Oct 14 06:10:41 CEST 2015
On 10/13/2015 8:01 PM, Erik wrote:
> On 13/10/15 23:19, Mark Lawrence wrote:
>> Stop pointlessly discussing something that simply is not going to happen.
>
> Huh?
>
> for each in range(3):
> foo()
>
> ... is already valid Python. In what way is that "not going to happen"?
What is not going to happen is that Python will not be changed to
actually make a particular identifier a dummy, by not, for instance,
letting it be used within the loop. I know you were not proposing that.
> This spelling was just suggested as an alternative to the original
> poster who did not like having to explain the cryptic "___" spelling to
> students.
What I think will not and should not happen is that Guido and/or core
devs 'bless' in PEP 8 any particular work for teaching beginners. Mark
gets a bit over-anxious sometimes, but insofar as he meant 'its futile
for us to try to decide on one spelling here', I think he is correct.
> Same construct, different spelling.
Right, and I think 'each' if better than '_' or '__' for beginners. I
recommend 'count' for range() and 'item' for a generic iterable. I also
recommend that teachers of beginners experiment with various choices,
and share their experiences with each other. Who knows, maybe kids would
prefer 'for kangaroo in range(3):', or other personal choices.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list