Python "why" questions

News123 news1234 at
Sat Aug 7 13:48:32 CEST 2010

On 08/07/2010 05:36 AM, Ryan Kelly wrote:
> On Fri, 2010-08-06 at 22:05 -0500, Default User wrote:
>> >From "the emperor's new clothes" department:
>> 1)  Why do Python lists start with element [0], instead of element
>> [1]?  "Common sense" would seem to suggest that lists should start
>> with [1].  

> "Common sense" is wrong.  There are many compelling advantages to
> numbering from zero instead of one:

It makes sense in assembly language and even in many byte code languages.
It makes sense if you look at the internal representation of unsigned
numbers (which might become an index)

For a complete beginner common sense dictates differently and there
might be confusion why the second element in a list has index 1.

However I seriously doubt, that this is a real problem.

You learn things like this on the first day of learning a programming

>> 2)  In Python 3, why is print a function only, so that: print "Hello,
>> World" is not okay, but it must be print("Hello, World") instead?
>> (Yeah, I know: picky, picky . . . )
> The real question is, why was print so special in Python 2 that is can
> be called without parentheses?  The answer was "no reason" and it was
> fixed in Python 3 to be consistent with the rest of the language.
>> 3)  In Python 3, why does 2.0 / 3.0 display as 0.6666666666666666, but
>> 8 * 3.57 displays as 28.56 (rounded off to 2 decimal places)?  And
>> yet, in Python 2.6, 8 * 3.57 displays as 28.559999999999999?
> Because the code for displaying floats was improved in python 3.  You
> can follow the fascinating discussion on issue 7117:
> I can't defend the rounding issues of floating point numbers in general
> - it's just "one of those things" that you have to deal with.  But show
> me a language where floats don't have this problem.
>> And we wonder why kids don't want to learn to program.  
I did not see the original post, but this statement sounds rather
trollish to me.

It might just be, that you can do so many things on a computer without
having to program. Watching youtube or browsing the web, chatting about
favourite PC games, the amount of SW, that you can download for almost
every task make it much less attractive to write own programs.

 When my parents had their first computer there were very little games
and PC's weren't connected to the net.
so if I wanted to play with the computer I had mostly the choice between
the games called:
- basic
- pascal
- word star
- super calc

Syntax details are barely a reason to frighten children.

children start very often with typing in small programs without
understanding them, lookin at the results and changing what they believe
to understand.

Non native english speakers can write programs, before they even knew
what the english words 'if' 'else' 'while' 'list' mean. They don't care.
They learn that if 'starts' a condition and that 'else' is the beginning
of the section to be executed if the condition is not true.

> Yeah, obscure language warts, that must be the reason.
> Note to self:  DNFTT...
>   Ryan

More information about the Python-list mailing list