Skip to content

Code examples contain Non-ASCII character #17

@heywiki

Description

@heywiki

When trying out code examples by copy & paste it from the browser into a sourcecode editor that uses UTF-8 by default, you at first don't recognize that some code examples contain non ASCII characters, which results in the error message

  File "<string>", line None
SyntaxError: Non-ASCII character in file 'wrong_encoding.py', but no encoding declared; se
see http://www.python.org/peps/pep-0263.html for details

This is very confusing for beginners , time consuming to figure out and breaks the flow when learning. When you switch the encoding of the file to ASCII, you then can see the error. The code examples actually use the wrong character, the minus in that case is not the real minus character, its dash from UTF-8 charset:

image

The example shown is from chapter 1, break statement:
https://jython.readthedocs.io/en/latest/chapter1/#break-statement

I also had a similar error with "sports team" example in chapter 3.
https://jython.readthedocs.io/en/latest/chapter3/#example-code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions