Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mitsuhiko/unicode-nazi
Annoying helper module that finds unicode/bytestring comparisions
https://github.com/mitsuhiko/unicode-nazi
Last synced: 3 months ago
JSON representation
Annoying helper module that finds unicode/bytestring comparisions
- Host: GitHub
- URL: https://github.com/mitsuhiko/unicode-nazi
- Owner: mitsuhiko
- License: other
- Created: 2011-01-22T15:34:40.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2011-03-11T01:49:15.000Z (almost 14 years ago)
- Last Synced: 2024-10-13T01:35:11.193Z (3 months ago)
- Language: Python
- Homepage:
- Size: 302 KB
- Stars: 74
- Watchers: 4
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README
- Changelog: CHANGES
- License: LICENSE
Awesome Lists containing this project
README
// The Unicode Nazi //
Once enabled the unicode nazi will complain whenever something is not
purely unicode or bytestring. It's annoying as hell and only useful
when porting over libraries from Python 2 to Python 3. It has a huge
runtime impact on performance and will also complain about most of the
stuff in the Python standard library.- usage:
>>> import unicodenazi
>>> 'foo' == u'foo'
__main__:1: UnicodeWarning: Implicit conversion of str to unicode
True- how to disable it again:
>>> unicodenazi.disable()
- and here is how to enable:
>>> unicodenazi.enable()
- if you want to enable it only for a given block:
>>> unicodenazi.disable()
>>> with unicodenazi.blockwise(enabled=True):
... assert 'foo' == u'foo'
...
__main__:2: UnicodeWarning: Implicit conversion of str to unicodeThe reverse works too of course.
The module can be used from a command line:
$ python -municodenazi your_script.py [script_args..]