[Python-Dev] Challenge about print >> None
M.-A. Lemburg
mal@lemburg.com
Fri, 08 Sep 2000 16:30:37 +0200
Vladimir Marangozov wrote:
>
> Seems like people are very surprised to see "print >> None" defaulting
> to "print >> sys.stderr". I must confess that now that I'm looking at
> it and after reading the PEP, this change lacks some argumentation.
According to the PEP it defaults to sys.stdout with the effect of
working just like the plain old "print" statement.
> In Python, this form surely looks & feels like the Unix cat /dev/null,
> that is, since None doesn't have a 'write' method, the print statement
> is expected to either raise an exception or be specialized for None to mean
> "the print statement has no effect". The deliberate choice of sys.stderr
> is not obvious.
>
> I understand that Guido wanted to say "print >> None, args == print args"
> and simplify the script logic, but using None in this case seems like a
> bad spelling <wink>.
>
> I have certainly carefully avoided any debates on the issue as I don't
> see myself using this feature any time soon, but when I see on c.l.py
> reactions of surprise on weakly argumented/documented features and I
> kind of feel the same way, I'd better ask for more arguments here myself.
+1
I'd opt for raising an exception instead of magically using
sys.stdout just to avoid two lines of explicit defaulting to
sys.stdout (see the example in the PEP).
BTW, I noted that the PEP pages on SF are not up-to-date. The
PEP 214 doesn't have the comments which Guido added in support
of the proposal.
--
Marc-Andre Lemburg
______________________________________________________________________
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/