3 ms·
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
by imh 11y ago
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.