[Python-checkins] CVS: python/nondist/peps pep-0214.txt,1.1,1.2

Barry Warsaw python-dev@python.org
Tue, 15 Aug 2000 15:45:09 -0700


Update of /cvsroot/python/python/nondist/peps
In directory slayer.i.sourceforge.net:/tmp/cvs-serv12763

Modified Files:
	pep-0214.txt 
Log Message:
Updated discussion, including two open issues.  I've also changed the
Python-Version to 2.1 since this probably needs more discussion,
unless the BDFL pronounces favorably on it.


Index: pep-0214.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0214.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** pep-0214.txt	2000/07/24 17:38:35	1.1
--- pep-0214.txt	2000/08/15 22:45:06	1.2
***************
*** 2,11 ****
  Title: Extended Print Statement
  Version: $Revision$
! Owner: bwarsaw@beopen.com (Barry A. Warsaw)
! Python-Version: 2.0
  Status: Draft
  
  
- 
  Introduction
  
--- 2,12 ----
  Title: Extended Print Statement
  Version: $Revision$
! Author: bwarsaw@beopen.com (Barry A. Warsaw)
! Python-Version: 2.1
  Status: Draft
+ Created: 24-Jul-2000
+ Post-History:
  
  
  Introduction
  
***************
*** 21,25 ****
  
  
- 
  Justification
  
--- 22,25 ----
***************
*** 53,58 ****
      to stdout, this output too would get redirected to the logfile.
  
  
! 
  Proposal
  
--- 53,60 ----
      to stdout, this output too would get redirected to the logfile.
  
+     This approach is also very inconvenient for interleaving prints to
+     various output streams.
  
! 
  Proposal
  
***************
*** 74,100 ****
          print >> sys.stdout, 'hello world'
  
  
- 
  Reference Implementation
  
      A reference implementation, in the form of a patch against the
      Python 2.0 source tree, is available on SourceForge's patch
!     manager[2].  The approach this patch takes is to introduce two new
!     opcodes, one which temporarily rebinds sys.stdout to the specified
!     file object, performs the print as normal, and then bind
!     sys.stdout back to sys.__stdout__ (which is the real physical
!     standard out and should not be changed).  In some ways this is
!     equivalent to the try/finally idiom above, except that the
!     rebinding of sys.stdout is in effect only for the duration of the
!     print statement itself.
! 
!     An alternative approach is possible, where only one new opcode is
!     added.  This opcode would be exactly like the existing PRINT_ITEM
!     opcode except that it would find the target file object at the top
!     of the stack, and use this file instead of digging it out of
!     sys.stdout.
  
  
- 
  Alternative Approaches
  
--- 76,116 ----
          print >> sys.stdout, 'hello world'
  
+ 
+ Open Issues
+ 
+     What should the following do?
+ 
+         print >> file
+         print >> file,
+ 
+     In the current implementation (see below), the first is a
+     SyntaxError and the second prints nothing to file.  This is likely
+     counterintuitive; the first should print just a newline, making
+     these equivalent:
+ 
+         print >> sys.stdout
+         print
+ 
+     The second should print just a space and no newline to file.  It
+     doesn't have a non-extended print equivalent, since this is
+     illegal:
+ 
+         print ,
+ 
+     The closes equivalent is:
+ 
+         print '',
+     
  
  Reference Implementation
  
      A reference implementation, in the form of a patch against the
      Python 2.0 source tree, is available on SourceForge's patch
!     manager[2].  This approach adds two new opcodes, PRINT_ITEM_TO and
!     PRINT_NEWLINE_TO, which simply pop the file like object off the
!     top of the stack and use it instead of sys.stdout as the output
!     stream.
  
  
  Alternative Approaches
  
***************
*** 140,144 ****
  
  
- 
  References
  
--- 156,159 ----