Skip to main content

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

This version
History Node

0.9.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
encodingcontext-0.9.0.tar.gz (1.7 kB) Copy SHA256 hash SHA256 Source None Sep 25, 2012

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page