aurora wrote:
> [...]In Java they are distinct data type and the compiler would catch all incorrect usage. In Python, the interpreter seems to 'help' us to promote binary string to unicode. Things works fine, unit tests pass, all until the first non-ASCII characters come in and then the program breaks.
Is there a scheme for Python developer to use so that they are safe from incorrect mixing?
Put the following:
import sys sys.setdefaultencoding("undefined")
in a file named sitecustomize.py somewhere in your Python path and Python will complain whenever there's an implicit conversion between str and unicode.
HTH, Walter Dörwald
That helps! Running unit test caught quite a few potential problems (as well as a lot of safe of ASCII string promotion).
--
http://mail.python.org/mailman/listinfo/python-list