Michael Hudson wrote: > Martin Blais <[EMAIL PROTECTED]> 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')
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 sys.setdefaultencoding("undefined"). Note that the codec "undefined" was added for just this reason. >>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. -- Marc-Andre Lemburg eGenix.com 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 ! :::: _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com