[Python-Dev] Challenge about print >> None

Barry A. Warsaw bwarsaw@beopen.com
Fri, 8 Sep 2000 11:27:24 -0400 (EDT)

>>>>> "VM" == Vladimir Marangozov <Vladimir.Marangozov@inrialpes.fr> writes:

    VM> Seems like people are very surprised to see "print >> None"
    VM> defaulting to "print >> sys.stderr". I must confess that now
    VM> that I'm looking at it and after reading the PEP, this change
    VM> lacks some argumentation.

sys.stdout, not stderr.

I was pretty solidly -0 on this extension, but Guido wanted it (and
even supplied the necessary patch!).  It tastes too magical to me,
for exactly the same reasons you describe.

I hadn't thought of the None == /dev/null equivalence, but that's a
better idea, IMO.  In fact, perhaps the printing could be optimized
away when None is used (although you'd lose any side-effects there
might be).  This would actually make extended print more useful
because if you used

    print >> logfile

everywhere, you'd only need to start passing in logfile=None to
disable printing.  OTOH, it's not to hard to use

    class Devnull:
        def write(self, msg): pass


We'll have to wait until after the weekend for Guido's pronouncement.