Show HN: Pattern matching and guards for Python functions (github.com) 6 points by rasguanabana 10y ago ↗ HN
[–] creshal 10y ago ↗ Example suggestion: Ensuring that an argument is a list of strings. I can't be the only one who wasted hours of debugging because I accidentally fed a string to a function expecting a list of strings. [–] guan 10y ago ↗ Can I use the generics introduced with the new type annotations in Python 3.5, so I can refer to Sequence[str] or something like that? [–] creshal 10y ago ↗ The problem is that every string is, internally, also a sequence of (single-character) strings. So it's not that easy. [–] rasguanabana 10y ago ↗ Thank you for suggestion, I have added a simple example.
[–] guan 10y ago ↗ Can I use the generics introduced with the new type annotations in Python 3.5, so I can refer to Sequence[str] or something like that? [–] creshal 10y ago ↗ The problem is that every string is, internally, also a sequence of (single-character) strings. So it's not that easy.
[–] creshal 10y ago ↗ The problem is that every string is, internally, also a sequence of (single-character) strings. So it's not that easy.
4 comments
[ 0.22 ms ] story [ 19.0 ms ] thread