printing non-ASCII characters - please explain
gh at ghaering.de
Sun Jun 15 14:02:32 CEST 2003
Helmut Jarausch wrote:
> please explain the following difference to me (with cvs-python)
> print N
> this prints Höfig which contains the Germain umlaut 'ö' = oe = \xf6
> print [N]
Because print invokes repr() on the object to print.
repr for lists is implemented in C, but if it were written in Python, it
would probably look like:
return "[%s]" % ", ".join([repr(x) for x in self.items])
> - and how can I change this?
Use an explicit function to format the list how you want it to be. If
you're not aware of the difference between str() and repr(), I'd
recommend you look them up in the Python documentation.
More information about the Python-list