Python is DOOMED! Again!

Nicholas Cole nicholas.cole at
Thu Jan 22 10:37:34 CET 2015

On Thu, Jan 22, 2015 at 8:10 AM, Mario Figueiredo <marfig at> wrote:
> In article <54c0a571$0$13002$c3e8da3$5496439d at>,
> steve+comp.lang.python at says...
>> The point isn't that there are no other alternative interpretations
>> possible, or that annotations are the only syntax imaginable, but that
>> they're not hard to guess what they mean, and if you can't guess, they're
>> not hard to learn and remember.
> Possibly one common use case will be Unions. And that factory syntax is
> really awful and long when you look at a function definition with as
> little as 3 arguments. The one below has only 2 arguments.
> def handle_employees(emp: Union[Employee, Sequence[Employee]], raise:
> Union[float, Sequence[float]]) -> Union[Employee, Sequence[Employee],
> None]:
> That's for a generic list-like container. Have fun with the Mapping
> union.

To be fair, is it clearer with some kind of formatting?

def handle_employees(
emp: Union[Employee, Sequence[Employee]],
raise: Union[float, Sequence[float]])
-> Union[Employee, Sequence[Employee], None]:

I still find that hard to read, but the line breaks help.  Just for
fun, I'd like to put out that without all of that noise the function

def handle_employees(employees, raise):
    return employees

And suddenly it looks like what most people who know anything about
programming recognise as Python again! With some kind of doc-string or
similar syntax it would read something like:

def handle_employees(employees, rasie):
    # employees: Union[Employee, Sequence[Employee]]
    # raise:  Union[float, Sequence[float]]
    # return: Union[Employee, Sequence[Employee], None]
    return employeees

There's a reasonable case that this is not all that dissimilar from
the function annotation syntax above, but the difference is surely
that in the one case you see immediately that there are two arguments,
and in the other you can't be sure without parsing some very cluttered
punctuation-heavy syntax.

Still, it would have been nicer to be able to write something like
this (where the Unions are implicit):

def handle_employees(employees, rasie):
    # employees: Employee, Sequence[Employee]
    # raise:  float, Sequence[float]
    # return: Employee, Sequence[Employee], None

Yes, I know that function annotations have been defined for a while,
and yes, I know that they are similar to a syntax used in other
languages, and yes, I know that they are optional.  All the same,
either they are going to become the norm or they are not. If they
become the norm (as I think they will because type hinting seems to
solve many problems that the community cares about) then I think we
have to accept that an important part of the language will become much
more cluttered, much less intuitive, and much more off-putting to

I think the fact that the current proposals mix the annotation syntax
with an inline comment syntax is also horrible (though I don't see any
alternatives).  I would much rather have put all of the "magic" in to
comments or none.


More information about the Python-list mailing list