opensubscriber
   Find in this group all groups
 
Unknown more information…

w : web-sig@python.org 5 January 2011 • 2:33AM -0500

Re: [Web-SIG] Declaring PEP 3333 accepted (was: PEP 444 != WSGI 2.0)
by Guido van Rossum

REPLY TO AUTHOR
 
REPLY TO GROUP




On Tue, Jan 4, 2011 at 7:48 AM, P.J. Eby <pje@tele...> wrote:
> At 06:30 PM 1/3/2011 -0800, Guido van Rossum wrote:
>>
>> Would
>>
>>  sys.stdout.buffer.write(b'abc')
>>
>> do?
>>
>> (If you mix this with writing strings to sys.stdout directly, you may
>> have to call sys.stdout.flush() first.)
>
> The current code is:
>
>            sys.stdout.write(data)  # TODO: this needs to be binary on Py3
>            sys.stdout.flush()
>
> Should I be using sys.stdout.buffer for both, or just the write?

For both.

But the flush() I was referring to is actually *before* either of
these, suggesting

sys.stdout.flush()
sys.stdout.buffer.write(data)
sys.stdout.buffer.flush()

However the first flush() is only necessary is there's a possibility
that previously something had been written to sys.stdout (not to
sys.stdout.buffer).

> For the CGI example in the PEP, I don't want to bother trying to make it
> fully production-usable; that's what we have wsgiref in the stdlib for.  So
> I won't worry about mixing strings and regular output in the example, even
> if perhaps wsgiref should add the StringIO's proposed by Graham.

Not sure what you mean. Surely copying and pasting the examples should
work? What are the details you'd like to leave out?

--
--Guido van Rossum (python.org/~guido)
_______________________________________________
Web-SIG mailing list
Web-SIG@pyth...
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: http://mail.python.org/mailman/options/web-sig/subscriber%40opensubscriber.com

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.