[Python-Dev] Divorcing str and unicode (no more implicit conversions).

Michael Hudson mwh at python.net
Mon Oct 3 10:43:06 CEST 2005


Martin Blais <blais at furius.ca> writes:

> What if we could completely disable the implicit conversions between
> unicode and str?  In other words, if you would ALWAYS be forced to
> call either .encode() or .decode() to convert between one and the
> other... wouldn't that help a lot deal with that issue?

I don't know.  I've made one or two apps safe against this and it's
mostly just annoying.

> How hard would that be to implement?

import sys
reload(sys)
sys.setdefaultencoding('undefined')

> Would it break a lot of code?  Would some people want that?  (I know
> I would, at least for some of my code.)  It seems to me that this
> would make the code more explicit and force the programmer to become
> more aware of those conversions.  Any opinions welcome.

I'm not sure it's a sensible default.

Cheers,
mwh

-- 
  It is never worth a first class man's time to express a majority
  opinion.  By definition, there are plenty of others to do that.
                                                        -- G. H. Hardy


More information about the Python-Dev mailing list