Python "why" questions
clp2 at rebertia.com
Sat Aug 7 07:33:55 CEST 2010
On Fri, Aug 6, 2010 at 8:05 PM, Default User <hunguponcontent at gmail.com> wrote:
> >From "the emperor's new clothes" department:
> 1) Why do Python lists start with element , instead of element ?
> "Common sense" would seem to suggest that lists should start with .
(In addition to the other good answers already given)
Well, "tradition" (originating from C) suggests otherwise. *Very* few
languages use 1-based indexing:
> 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 . . . )
One less special case to learn; makes the language more regular and
easier to learn. It also lets one write:
f = lambda x: print(x)
Which is not possible if print is a statement.
More information about the Python-list