[Python-Dev] Round Bug in Python 1.6?

Guido van Rossum guido at python.org
Fri Apr 7 21:18:40 CEST 2000


> Just checking my newly bought "Guido Channeling" kit -- you mean str()
> but special case the snot out of strings(TM), don't you

Except I'm not sure what kind of special-casing should be happening.

Put quotes around it without worrying if that makes it a valid string
literal is one thought that comes to mind.

Another approach might be what Tk's text widget does -- pass through
certain control characters (LF, TAB) and all (even non-ASCII) printing
characters, but display other control characters as \x.. escapes
rather than risk putting the terminal in a weird mode.  No quotes
though.  Hm, I kind of like this: when used as intended, it will just
display the text, with newlines and umlauts etc.; but when printing
binary gibberish, it will do something friendly.

There's also the issue of what to do with lists (or tuples, or dicts)
containing strings.  If we agree on this:

>>> "hello\nworld\n\347" # octal 347 is a cedilla
hello
world
ç
>>>

Then what should ("hello\nworld", "\347") show?  I've got enough serious
complaints that I don't want to propose that it use repr():

>>> ("hello\nworld", "\347")
('hello\nworld', '\347')
>>>

Other possibilities:

>>> ("hello\nworld", "\347")
('hello
world', 'ç')
>>>

or maybe

>>> ("hello\nworld", "\347")
('''hello
world''', 'ç')
>>>

Of course there's also the Unicode issue -- the above all assumes
Latin-1 for stdout.

Still no closure, I think...

--Guido van Rossum (home page: http://www.python.org/~guido/)




More information about the Python-list mailing list