Python is DOOMED! Again!
marfig at gmail.com
Thu Jan 22 09:10:34 CET 2015
In article <54c0a571$0$13002$c3e8da3$5496439d at news.astraweb.com>,
steve+comp.lang.python at pearwood.info 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],
That's for a generic list-like container. Have fun with the Mapping
Meanwhile there's quite a few more generics like the Sequence one above
you may want to take a look at and try and remember. And that's just one
factory (the generics support factory). You may also want to take a look
at TypeVar and Callable for more syntactic hell.
Meanwhile, there's the strange decision to implement type hints for
local variables # comment lines. I have an hard time wrapping my head
around this one. Really, comments!?
Finally, remember all this is being added to your code just to
facilitate static analysis. Strangely enough though I was taught from
the early beginning that once I start to care about types in Python, I
strayed from the pythonic way. I'm confused now... What is it then?
More information about the Python-list