Skip to content

Instantly share code, notes, and snippets.

@victorono
Created January 16, 2017 15:51
Show Gist options
  • Save victorono/d3b9c689d466689e581f78489ad3fdf1 to your computer and use it in GitHub Desktop.
Save victorono/d3b9c689d466689e581f78489ad3fdf1 to your computer and use it in GitHub Desktop.
python 3 unicode migration
try:
unicode = unicode
except NameError:
# 'unicode' is undefined, must be Python 3
str = str
unicode = str
bytes = bytes
basestring = (str, bytes)
else:
# 'unicode' exists, must be Python 2
str = str
unicode = unicode
bytes = str
basestring = basestring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment