Python handles globals badly.

Ian Kelly ian.g.kelly at gmail.com
Tue Sep 8 16:31:04 CEST 2015


On Tue, Sep 8, 2015 at 5:55 AM, Vladimir Ignatov <kmisoft at gmail.com> wrote:
>>> I had some experience programming in Lua and I'd say - that language
>>> is bad example to follow.
>>> Indexes start with 1  (I am not kidding)
>>
>> What is so bad about that?
>
> It's different from the rest 99.9% of languages for no particular reason.

It's not "different from the rest 99.9% of languages". There are many
languages that use 1-based indexing, e.g. Matlab, Pascal, Fortran.

None of those are even the worst offender here, IMO. That honor goes
to Visual Basic 6, where the default lower bound is 0, but the
programmer has the option of declaring an array to use any lower bound
they want, or even globally change the default. As a result you have
to look up the array declaration to know the lower bound, and even
then you can't be sure if it's not explicit. The correct way to
iterate over a loop in VB 6 is thus not "FOR i = 0 TO n-1", but "FOR i
= LBound(arr) TO UBound(arr)" which is overly verbose and means that
you can't even be sure what indexes you're actually iterating over
inside the loop.

I believe this wart is fixed in VB .NET.


More information about the Python-list mailing list