PEP 214, extended print statement

Al-Amerrho H. Amerin al_amerin at yahoo.com
Thu Aug 17 02:08:18 EDT 2000


Doesn't this look much better and more intuitive ( my subjective opinion ) ?

     print  'this message goes to my log file' >> mylogfile

a-la shell script. I'm sorry if this has been discussed before...

Al-

In article <14746.44861.78992.343012 at anthem.concentric.net>,
bwarsaw at beopen.com (Barry A. Warsaw) wrote:

> 
> After channeling and encouragement by Tim Peters, I've updated PEP
> 214, the extended print statement.  Text is included below, but is
> also available at
> 
>     http://python.sourceforge.net/peps/pep-0214.html

.  An example usage is as follows:
> 
>         print >> mylogfile, 'this message goes to my log file'
> 
>     Formally, the syntax of the extended print statement is
>     
>         print_stmt: ... | '>>' test [ (',' test)+ [','] ] )
> 
>     where the ellipsis indicates the original print_stmt syntax
>     unchanged.  In the extended form, the expression just after >> must
>     yield an object with a write() method (i.e. a file-like object). 
>     Thus these two statements are equivalent:
> 
> 	print 'hello world'
>         print >> sys.stdout, 'hello world'
> 
>     As are these two statements:
> 
>         print print >> sys.stdout
> 
>     These two statements are syntax errors:
> 
>         print , print >> sys.stdout,
>



More information about the Python-list mailing list