Last active
December 22, 2015 08:58
-
-
Save mbylstra/6448401 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
#modified version off http://code.activestate.com/recipes/576602-safe-print/ | |
def sprint(*args, **kwargs): | |
"""Safely print the given string. | |
If you want to see the code points for unprintable characters then you | |
can use `errors="xmlcharrefreplace"`. | |
""" | |
errors = kwargs.get('errors', 'replace') | |
for s in args: | |
s = s.encode(sys.stdout.encoding or "utf-8", errors) | |
print(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment