3 ms·
Looking at the usage of is_integer, personally I would write something like parse_integer(x: str) -> Optional[int], where the None variant represents a caught V
by rollcat 4y ago
Looking at the usage of is_integer, personally I would write something like parse_integer(x: str) -> Optional[int], where the None variant represents a caught ValueError; this avoids parsing the integer twice but achieves basically the same effect (in a very similar style).
What would you propose as "more pythonic" here? Writing your own integer parsing code, by looking at the ASCII values of each character in the string?