Skip to content

Instantly share code, notes, and snippets.

@nitori
Last active August 30, 2023 09:08
Show Gist options
  • Select an option

  • Save nitori/e9704b249526296c1e5701cd9822cbf7 to your computer and use it in GitHub Desktop.

Select an option

Save nitori/e9704b249526296c1e5701cd9822cbf7 to your computer and use it in GitHub Desktop.
import sys
def int_succeeds(c: str):
try:
int(c)
except ValueError:
return False
return True
chars = [chr(n) for n in range(sys.maxunicode + 1)]
numerics = {c for c in chars if c.isnumeric()}
digits = {c for c in chars if c.isdigit()}
decimals = {c for c in chars if c.isdecimal()}
print('No. numerics:', len(numerics))
print('No. digits:', len(digits))
print('No. decimals:', len(decimals))
print('numerics \N{SUPERSET OF} digits \N{SUPERSET OF} decimals:', numerics > digits > decimals)
print('int() on all numerics:', all(int_succeeds(c) for c in numerics))
print('int() on all digits:', all(int_succeeds(c) for c in digits))
print('int() on all decimals:', all(int_succeeds(c) for c in decimals))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment