1 2 3 4 5 6 7 8
import typing def try_int(s: str) -> typing.Optional[int]: try: return int(s) except ValueError: return None