Skip to content

Instantly share code, notes, and snippets.

@luispedro
Created May 3, 2010 17:31
Show Gist options
  • Save luispedro/388348 to your computer and use it in GitHub Desktop.
Save luispedro/388348 to your computer and use it in GitHub Desktop.
is_ascii
def is_ascii(s):
'''
ascii = is_ascii(s)
Check whether a unicode string is ASCII
'''
try:
s = s.encode('ascii')
return True
except UnicodeError:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment