[Web-SIG] The write callable (vs. file-like object)

Ian Bicking ianb at colorstudy.com
Tue Aug 31 05:07:51 CEST 2004


Another comment I meant to make, but forgot about amid exceptions.  The 
write callable is a bit awkward, because most code wants a file-like 
object, not a callable.  So I had to do the dumb thing of creating a 
fake instance with one "write" instance variable.  That feels silly.  I 
think I'd prefer if the return value from start_response was a file-like 
object.

Arguably, where the callable is harder to use, it's easier to produce. 
E.g., you could pass a bound method (that's not write) as the callable, 
like aList.append.  So I'm not sure about this.  OTOH, returning a 
file-like object leaves open more room for extension.  Like, the ability 
to write unicode; even if we leave it out now I don't see any good place 
where that could be added in the future, as the interface is rather 
minimal in that area.  But my thinking is a little fuzzy in that area.

-- 
Ian Bicking  /  ianb at colorstudy.com  / http://blog.ianbicking.org


More information about the Web-SIG mailing list