Python is DOOMED! Again!

Nicholas Cole nicholas.cole at gmail.com
Thu Jan 22 00:50:52 EST 2015


I don't think that Python is doomed. I *do* think that type-hinting is
useful, and Python has borrowed a syntax that is similar to that used in
other languages, so that it is a familiar one to many developers.

It is a stretch to call it intuitive though, either to write or to
read. Personally, I would have favoured a doc string solution. The magic
comments that are part of the current proposal are genuinely intuitive, I
think. The function definition syntax is something to be learned and which
it takes me a little time to process even though I'm getting used to it. I
find that it's still a slight effort to remember which way around the name
of the argument and the type go. I'm sure I've seen one language that does
the oppoosite, and the fraction of a second it takes me to remember is a
tiny friction. There's no doubt, too, that long function definitions
(Python functions tend to have lots of arguments in the real world) are
going to look cluttered, and cluttered by lots of magic punctuation.

So useful, yes. Familiar already to those who use other languages, yes.
Intuitive, no. And there is a linguistic reason for that:

Consider this:

Define function add taking price1, price2, print_error equals true.

Yes, Python wouldn't understand that, but turning it in to a valid
definition requires only a tiny amount of effort.

Type definitions add a whole level of complexity:

Define function add taking the float price1, the float price2, print_error
equals the Boolean true. Make the function return a float.

Converting that into python simply requires more effort: in other words the
gap between what one might say in speech and what the code looks like is
bigger.

The reason for this is that a lot of information is being compressed in to
a small space. In English writing it is usually clearer to avoid long and
complicated sentences with lots of subclauses (even if they make perfect,
logical sense) in favour of shorter ones, and I think there is a parallel
here.

I would have preferred Python to mimic:

Define function add taking price1, the price2, print_error equals true.
Price1 is a float. Price2 is a float. The function returns a float.

But now this is sounding a little like something from Larry Wall, and so I
had better stop!  I wasn't trying to re-litigate the decisions that have
been taken, just to understand the friction.

Just my £0.2

Nicholas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150122/06ce22c5/attachment.html>


More information about the Python-list mailing list