[Patches] [Patch #100970] extended print statement

noreply@sourceforge.net noreply@sourceforge.net
Tue, 15 Aug 2000 16:33:15 -0700


Patch #100970 has been updated. 

Project: 
Category: core (C code)
Status: Open
Summary: extended print statement

Follow-Ups:

Date: 2000-Jul-23 19:44
By: bwarsaw

Comment:
This patch provides one approach to an extended print statement which allows you to specify the file-like object to print to (instead of the default sys.stdout).  This adds two new opcodes and works by temporarily binding sys.stdout during the execution of the print statement.

An alternative approach would be to include one new opcode, called PRINT_ITEM_TO which would put the file-like object on top of the stack for each call to PRINT_ITEM.  I'm not sure which approach is better.
-------------------------------------------------------

Date: 2000-Jul-23 19:45
By: bwarsaw

Comment:
The following is an example of how you might use the new extended print statement.

<pre>
import sys
from StringIO import StringIO

listname = 'mylist'
sender = 'barry@beopen.com'
msg = 'x' * 1000

print 'post to', listname, 'from', sender, 'size=', len(msg)
print >> sys.stdout, 'post to', listname, 'from', sender, 'size=', len(msg)

log = StringIO()
print >> log, 'post to', listname, 'from', sender, 'size=', len(msg)
print log.getvalue(),
</pre>

-------------------------------------------------------

Date: 2000-Aug-15 11:00
By: tim_one

Comment:
Assigned to Guido for Pronouncement.  This was already discussed on Python-Dev.  Mix of opinions there.  I like it fine.

Barry, this needs docs and test cases Real Soon if you want it considered for 2.0.  I like the PRINT_TO idea better.
-------------------------------------------------------

Date: 2000-Aug-15 15:43
By: bwarsaw

Comment:
Revised patch which uses the PRINT_ITEM_TO approach favored by Tim.  This patch also includes doc and test suite updates.  Please see PEP 214 for a discussion of the issues.  This feature should be postponed until Python 2.1
-------------------------------------------------------

Date: 2000-Aug-15 16:05
By: tim_one

Comment:
I don't understand.  If you wanted to Postpone it, you could have done so yourself.  Why do you want to postpone it?  It's already been discussed, and the patch was submitted well before the feature-freeze date.
-------------------------------------------------------

Date: 2000-Aug-15 16:16
By: bwarsaw

Comment:
Okay, I just thought that with the open issue (see PEP 214) it might not be ready for prime time.  Let's wait for the BDFL pronounce before postponing.
-------------------------------------------------------

Date: 2000-Aug-15 16:33
By: tim_one

Comment:
I don't understand.  If you wanted to Postpone it, you could have done so yourself.  Why do you want to postpone it?  It's already been discussed, and the patch was submitted well before the feature-freeze date.
-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=100970&group_id=5470