[Python-ideas] Python Isn't Perfect: adding a 'gotchas' section to the tutorial
masklinn at masklinn.net
Mon Dec 12 00:31:11 CET 2011
On 2011-12-11, at 22:30 , Richard Prosser wrote:
> However I still feel that there are some aspects of the language which are
> not in the true spirit of Python (i.e. 'intuitive').
I have to note that, as far as I know, "intuitive" is not quite part of the
"true spirit of Python". The Zen even has a stanza on the subject:
> Although that way may not be obvious at first unless you're Dutch.
> It seems to me
> that the essential problem is that of assignment in general, which (I
> believe) creates a reference on the LHS to the object on the RHS, rather
> than having a copy operation to make the two objects completely separate.
I don't see this as a problem, it's the normal semantics of languages using
reference-values for object types.
> A similar comment applies to the lack of type declarations.
> So if you or anyone else can explain exactly why such odditties are
> implemented I would be grateful.
I don't understand, why do you consider dynamic typing to be "an
oddity"? There is nothing odd about it, and it's in fact older than
computer science itself.
The default arguments issue is an unfortunate interaction of Python's
core reference-value semantics and default arguments being implemented
as attributes to the function object, evaluated when said function
object is created (the feature itself is as old as Python, according to
the logs it was added for the 1.0.2 release back in 1994, the changelog
seems to peg it to April 14, so your only chance for an explanation of
why it was implemented with these semantics is hoping Guido has a very,
very good memory. Numerous post-hoc rationalization exist, but only him
may hold the true reason).
> Unfortunately it is almost certainly too late to propose fixes (if
> appropriate) for such quirks in Python 3
Most of these have been core semantic attributes of the language for
almost two decades now, so even if you had proposed these changes
during the Python 3 design cycle I think it's very unlikely they'd
have passed: they don't just change Python, they create a very
different language with a syntax similar to Python's.
More information about the Python-ideas