News for hackers. Stuff that matters.
Re:Type hints – a mediocre programmer's reaction (2015) by imh on Friday March 18, 2016 @02:34AM (#11310287)
This is totally crazy. With a slightly different syntax it's really not so bad:

{a:b} for mappings from a to b

(a,b) for tuples of a and b

[a] for iterables of a

a | b for unions of a and b

Then factor out that nasty common thing and you end up with:

    Optional[    {basestring: StringThing}
              | [(basestring, StringThing)]
            ]

    StringThing = (basestring, Optional[basestring | file]])
                | (basestring, Optional[basestring | file]], Optional[basestring])
                | (basestring, Optional[basestring | file]], Optional[basestring], Optional[Headers])    

    Headers =  {basestring: basestring}
            | [(basestring, basestring)]
It's not inherently complicated nor does it have anything to do with duck typing, it's just that the syntax chosen is awful.

There are no comments on this comment yet.