Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Type hints – a mediocre programmer's reaction (2015).
{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)]
There are no comments on this comment yet.
{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:
It's not inherently complicated nor does it have anything to do with duck typing, it's just that the syntax chosen is awful.