[Python-Dev] Divorcing str and unicode (no more implicit conversions).
mal at egenix.com
Mon Oct 3 11:43:13 CEST 2005
Michael Hudson wrote:
> 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
You shouldn't post tricks like these :-)
The correct way to change the default encoding is by
providing a sitecustomize.py module which then call the
Note that the codec "undefined" was added for just this
>>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.
Me neither, especially since this would make it impossible
to write polymorphic code - e.g. ', '.join(list) wouldn't
work anymore if list contains Unicode; dito for u', '.join(list)
with list containing a string.
Professional Python Services directly from the Source (#1, Sep 30 2005)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the Python-Dev