[Python-Dev] Challenge about print >> None
Vladimir Marangozov
Vladimir.Marangozov@inrialpes.fr
Fri, 8 Sep 2000 21:27:06 +0200 (CEST)
Barry A. Warsaw wrote:
>
>
> >>>>> "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.
typo
>
> 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
>
>
> logfile=Devnull()
In no way different than using a function, say output() or an instance
of a Stream class that can poke at will on file objects, instead of
extended print <0.5 wink>. This is a matter of personal taste, after all.
>
> We'll have to wait until after the weekend for Guido's pronouncement.
>
Sure. Note that I don't feel like I'll loose my sleep if this doesn't
change. However, it looks like the None business goes a bit too far here.
In the past, Guido used to label such things "creeping featurism", but
times change... :-)
--
Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252