[Python-Dev] PEP 484 syntax: NONONONONONONO!

Benjamin deisum at gmail.com
Sun Feb 1 11:13:42 CET 2015


The proposed syntax is abominable. It's the opposite of readable.

The function annotation syntax is ugly, but potentially useful for things
like documentation. While it may very well have been created with the idea
of type-checking, actually using it for such quickly turns into an
unreadable morass of information that is far more difficult for human
brains to parse, which makes this usage the antithesis of pythonic.

I much prefer the idea of a 'where' keyword to denote typing, as discussed
http://aroberge.blogspot.com/2015/01/type-hinting-in-python-focus-on.html,
but I think a refinement of their idea would prove even better:

def retry(callback, timeout, retries=None) where
........callback is Callable[AnyArgs, Any[int, None]],
........timeout is Any[int, None],
........retries is in [int, None], # 'is in' construct is more readable,
dunno about complexity
........return is None:
....pass

def greeting(name) where name is str, return is str:
....return 'Hello ' + name

x, y = [], [] where x, y is List[Employee], List[Manager]

To me, this orders of magnitude more readable than the proposed nonsense.

PS. Obviously the 8-space indent above would only a convention, not
requirement.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150201/72918759/attachment.html>


More information about the Python-Dev mailing list