Python handles globals badly.
torriem at gmail.com
Wed Sep 9 01:55:02 CEST 2015
On 09/08/2015 09:56 AM, Steven D'Aprano wrote:
> It's a wonderful read.
I read this article, but I'm still uncertain to what his point actually
is. It's a great review of the history of C, some batch computing, and
IBM's CEO's penchant for boat racing. He tries to say that 0-based
indexing made for faster compiling, but given the runtime nature of
BCPL's ! operator, I don't see how it wouldn't affect runtime also. He
also says that saying pointers are the reason for 0-based indexing then
you're wrong, except that BCPL's creator says in this same article that
array variables are essentially pointers. A few people tried to point
this out in the comments but the author simply lambasted them, saying
thinks like, "Thanks for leaving a comment. I'm sure it's made you feel
clever." Like I say I guess I must have missed his point in there
somewhere. I suppose his point is C is 0-based because BCPL was, and
I'm sure that's true, but I'm also sure K&R saw some benefits to keeping
this in C.
In any case, 0-based indexing in Python makes a lot of sense when you
bring in the slicing syntax. Especially if you think of slicing as
operating on the boundaries between cells as it were.
I used a 1-based indexed language (BASIC) for many years, and I was
always having to subtract 1 from things. So 0-based is simply more
convenient for me.
More information about the Python-list