In praise of PEP 214 (was RE: what kind of work do you do)

Tim Peters tim_one at email.msn.com
Thu Aug 24 03:15:05 EDT 2000


[Alex]
> My opinion doesn't count for anything wrt what goes into python2.0, but
> I'd be very suprised if the C++ stream syntax makes it.

I'd personally die of shock if C++ stream syntax were adopted in any version
of Python, but note that the proposal under discussion [PEP 214] was already
accepted and is in the 2.0 tree.  Any connection to C++ streams is fantasy.
Old-timers look at this and say "ah, fudge! now there are *two* forms of
'print'! my head will explode!!":

1.   print          stuff
2.   print >> file, stuff

(and note that #2 is the entire proposal:  print grows an option, and that's
all)

That's not how newbies will see it, though:  two years from now on c.l.py,
"almost everyone" will believe that #2 *is* Python's "print" stmt, and that
#1 was introduced as convenient syntactic sugar for the common

     print >> sys.stdout, stuff

I've used this a few times now with sys.stderr, and I don't ever want to go
back -- it's Pythonic, and not just cuz Guido said it is.  For an example of
what *isn't* Pythonic, just glance back at the last week's responses to the
user who asked how to print to a file other than stdout.  The poor sod was
buried in tricks with __xxx__ vrbls and try/finally blocks before they could
ask "hmm! I wonder whether it's such a bloody pain in Perl?" <wink>.

has-been-one-of-the-faqiest-of-faqs-and-one-of-the-most-consistently-
    poorly-answered-ly y'rs  - tim






More information about the Python-list mailing list