Why don't we call the for loop what it really is, a foreach loop?
Grant Edwards
grant.b.edwards at gmail.com
Tue Sep 13 18:00:45 EDT 2016
On 2016-09-13, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Tue, Sep 13, 2016 at 2:57 PM, <rgrigonis at gmail.com> wrote:
>> It would help newbies and prevent confusion.
>
> Ada uses "for".
[a dozen or so other langages]
> Swift uses "for".
>
> Why do you think it's confusing that Python uses the same keyword in
> its foreach loops that all the above languages do? What mistake is
> this causing newbies to make?
One might guess that the OP is coming from PHP where there are
separate "for" and "foreach" looping constructs, and Python's "for" is
analogous to PHP's "foreach".
That said, I despise PHP so thoroughly that "because PHP does it" is,
to me, a pretty strong argument for _not_ doing something.
Even trying to ignore my bias agains PHP, I can't see that Python's
calling it "for" instead of "foreach" is going to confuse anybody with
a PHP background...
--
Grant Edwards grant.b.edwards Yow! I have accepted
at Provolone into my life!
gmail.com
More information about the Python-list
mailing list