[Python-Dev] Challenge about print >> None

Vladimir Marangozov Vladimir.Marangozov@inrialpes.fr
Tue, 12 Sep 2000 20:51:21 +0200 (CEST)


Christian Tismer wrote:
> 
> > Vladimir wrote:
> > > I understand that you want me to think this way. But that's not my
> > > intuitive thinking. I would have written your example like this:
> > >
> > > def func(file=sys.stdout):
> > >     print >> file, args
> > >
> > > This is a clearer, compared to None which is not a file.
> 
> This is not clearer.
> Instead, it is presetting a parameter
> with a mutable object - bad practice!

I think I mentioned that default function args and explicit output
streams are two disjoint issues. In the case of extended print,
half of us perceive that as a mix of concepts unrelated to Python,
the other half sees them as natural for specifying default behavior
in Python. The real challenge about print >> None is that the latter
half would need to explain to the first one (including newcomers with
various backgrounds) that this is natural thinking in Python. I am
sceptical about the results, as long as one has to explain that this
is done on purpose to someone who thinks that this is a mix of concepts.

A naive illustration to the above is that "man fprintf" does not say
that when the stream is NULL, fprintf behaves like printf. Indeed,
fprintf(NULL, args) dumps core. There are two distinct functions for
different things. Either you care and you use fprintf (print >> ),
either you don't care and you use printf (print). Not both. If you
think you can do both in one shot, elaborate on that magic in the PEP.

-- 
       Vladimir MARANGOZOV          | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252