A bad idea about the default encoding
Project description
Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.—Zen of Python
This small module implements a bad idea: making default encoding explicitly scoped:
>>> with encoding_context('euc-kr'):
... str(u'\ud55c\uae00')
...
'\xc7\xd1\xb1\xdb'
Of course it has several shortcomings, and the most critical one is: using it within thread, threading, greenlet, tasklet, etc probably breaks its scoping. If Python had dynamic scoping and default encoding was defined as dynamically scoped variable, we might have more convenient way to code between Unicode–byte strings.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
encodingcontext-0.9.0.tar.gz
(1.7 kB
view details)
File details
Details for the file encodingcontext-0.9.0.tar.gz
.
File metadata
- Download URL: encodingcontext-0.9.0.tar.gz
- Upload date:
- Size: 1.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 404a963c376817a158b41a6e0353a1d73823619b60cbf6a6f9bfb708fd9ef9f4 |
|
MD5 | 6a6c639ec3dcc40d4cdc5d3beb53d810 |
|
BLAKE2b-256 | a58e88c6008103c3b79909cc44353ea015d608e5537ec11d9eaa6d62995ba08f |