Created
March 18, 2017 13:12
-
-
Save scott-w/325fc5d996edbb22fb8da09dd8f1b3d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, print_function, unicode_literals | |
from six import string_types, text_type, binary_type | |
## Python 2 only | |
some_value = 20 | |
value_as_string = unicode(some_value) | |
value_as_bytes = str(some_value) | |
isinstance(value_as_string, basestring) | |
## Using six, this becomes | |
some_value = 20 | |
value_as_string = text_type(some_value) | |
value_as_bytes = binary_type(some_value) | |
isinstance(value_as_string, string_types) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment