4 ms·
One serious problem not addressed in Python type checking is that there's no Char type: you cannot type hint a function to only accept an iterable of strings wi
by yegle 7y ago
One serious problem not addressed in Python type checking is that there's no Char type: you cannot type hint a function to only accept an iterable of strings without accidentally accept str itself. The best thing you can do is a Union of all possible types.
That's why I think the type hinting thing is always a bandaid.
- hannofcart 7y agoThis really is nitpicking. Not having a Char type is something that has seriously affected you? Honestly, how often have you had to write a function that strictly takes a char and not string? In a decade of programming professionally, I can probably count 3.
- joshuamorton 7y agohttps://github.com/joshuamorton/pytype/commit/5cd7a15613b883b3ff6acdbaf0fdde032c85519c https://github.com/joshuamorton/pytype/commit/5cd7a15613b883... It's actually a fairly easy to fix issue for the most part, but I don't have time to push for inclusion/adoption.
- rurban 7y agoStrings are arrays of ints, not chars. You can easily create such a limited bastard Array[Uint8] by yourself, but don't call it string then, but bytes.
- dragonwriter 7y ago> One serious problem not addressed in Python type checking is that there's no Char type That's not a typechecking issue so much as a type structure issue; “there's no Char type” isn't a problem of (any of the) Python typecheckers, Python simply has never had a char type; strings are iterables whose members are strings which, while drawn from a specific subset, do not have a distinct type. This may be a type system problem, but it's not a type hinting problem.,