[Python-Dev] Round Bug in Python 1.6?

Tim Peters tim_one@email.msn.com
Sun, 9 Apr 2000 22:40:03 -0400


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

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

Welcome to the club.

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

If nothing else <wink>, Ping convinced me the temptation to type that back
in will prove overwhelming.

> 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.

This must be platform-dependent?  Just tried this loop in Win95 IDLE, using
Courier:

>>> for i in range(256):
	print i, chr(i),

Across the whole range, it just showed what Windows always shows in the
Courier font (which is usually a (empty or filled) rectangle for most
"control characters").  No \x escapes at all.

BTW, note that Tk unhelpfully translates a request for "Courier New" into a
request for "Courier", which aren't the same fonts under Windows!  So if
anyone tries this with the IDLE Windows defaults, and doesn't see all the
special characters Windows assigns to the range 128-159 in Courier New,
that's why -- most of them aren't assigned under Courier.

> 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.

Can't be worse than what happens now <wink>.

> 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
> ç
> >>>

I don't think there is agreement on this, because nothing in the output says
"btw, this thing was a string".  Is that worth preserving?  "It depends" is
the only answer I've got to that.

> 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''', 'ç')
> >>>

I like the last best.

> Of course there's also the Unicode issue -- the above all assumes
> Latin-1 for stdout.
>
> Still no closure, I think...

It's curious how you invoke "closure" when and only when you don't know what
*you* want to do <wink>.

a-guido-divided-against-himself-cannot-stand-ly y'rs  - tim