[Doc-SIG] non-ascii docstrings

Fredrik Lundh fredrik at pythonware.com
Tue Mar 28 18:48:37 CEST 2006


Laura Creighton wrote:

> Indeed, in the matter of encoding, I wish that python would guess
> a whole lot more.  One of the most common 'first python programs'
> that non-computer people write is 'my phonelist manager' and another is
> 'my cd collection manager'.  I think that they have plenty enough
> to worry about without needing to find out about encodings before
> their first python program runs.  Most places _have_ a locale sort
> of setting, and I would be in favour of trying whatever is there
> when encountering something that is not ascii.

as long as the interpreter prints a warning when it falls back on the
default...  oh, wait.

$ python2.2 welcome.py
Welcome to Linköping

$ python2.3 welcome.py
sys:1: DeprecationWarning: Non-ASCII character '\xf6' in file welcome.py on line 1, but no encoding declared; see
http://www.python.org/peps/pep-0263.html for details
Welcome to Linköping

$ python2.4 welcome.py
sys:1: DeprecationWarning: Non-ASCII character '\xf6' in file welcome.py on line 1, but no encoding declared; see
http://www.python.org/peps/pep-0263.html for details
Welcome to Linköping

$ python2.5 welcome.py
  File "welcome.py", line 1
SyntaxError: Non-ASCII character '\xf6' in file /users/fredrik/welcome.py on line 1, but no encoding declared; see
http://www.python.org/peps/pep-0263.html for details

guess this means that newbies should make sure to run their first
program under multiple Python versions...

</F>





More information about the Doc-SIG mailing list