[Python-Dev] Type hints -- a mediocre programmer's reaction (original) (raw)
Terry Reedy tjreedy at udel.edu
Wed Apr 22 08:32:18 CEST 2015
- Previous message (by thread): [Python-Dev] Type hints -- a mediocre programmer's reaction
- Next message (by thread): [Python-Dev] Type hints -- a mediocre programmer's reaction
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 4/21/2015 6:41 PM, Chris Barker wrote:
Well, it'll catch passing in a string instead of a sequence of strings -- one of teh common and semi-insidious type errors I see a lot (at least with newbies).
Oh wait, maybe it won't -- a string IS a sequence of strings. That's why this is an insidioous bug in teh first place: List[string] will work, yes -- but now I'm locked down the user to an actual, list, yes? So I try: Iterable[string] ah yes -- now users can use tuples of strings, or a custom class, or -- but wait, darn it, a string IS an iterable of strings.. SIGH.
I was just thinking today that for this, typing needs a subtraction (difference) operation in addition to an addition (union) operation: Difference(Iterable(str), str)
-- Terry Jan Reedy
- Previous message (by thread): [Python-Dev] Type hints -- a mediocre programmer's reaction
- Next message (by thread): [Python-Dev] Type hints -- a mediocre programmer's reaction
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]