From: Chuck E. <ChuckEsterbrook@StockAlerts.com> - 2002-06-19 21:59:43
|
On Wednesday 19 June 2002 02:50 pm, Jeff Johnson wrote: > > I agree that using str() to attempt to convert to a string is > > questionable. > > > I'd prefer to just raise the exception. But I'm willing to be > > convinced otherwise... > > > > I'm not entirely sure where this issue originated. Would > > converting using str() have helped in some way to diagnose the > > problem? > > > > - Geoff > > I suppose the reason I ask if we should convert to strings is because > I equate Python's print with Webware's write. But print will print > anything, write will only accept strings. Chuck already pointed out > a few good reasons why they are not the same, escaping HTML > characters and such, so I'm happy to change my way of thinking and > agree that HTTPResponse.write should only accept strings. > > - Jeff Also, I think of HTTPResponse.write like file's write(). >>> import sys >>> f = sys.stdout >>> f.write(1) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: argument must be string or read-only character buffer, not int >>> -Chuck |