Misleading wikipedia article on Python 3?

Paul Boddie paul at boddie.org.uk
Wed Aug 8 18:08:40 CEST 2007


On 8 Aug, 16:26, Istvan Albert <istvan.alb... at gmail.com> wrote:
> On Aug 6, 6:11 am, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
>
> > Why on earth did they make this change?  It just seems gratuitous.
>
> Having print a function (with parameters) makes is very easy to modify
> where the output goes.

I'm not arguing with this.

> Say you want to have some prints go to one particular file, today you
> cannot easily do it, you have to either do a regex based search/
> replace or fiddle with the sys.stdout etc. both have substantial
> drawbacks.

Well, you could find all print statements reliably using various
parsing solutions provided with Python. It's interesting that for this
reason, migrating from the print statement is not particularly
difficult whereas identifying invocations of the upcoming print built-
in function will not be a trivial task. I'm not passing judgement on
the introduction of the print function here, but I find such
properties of the language very interesting - it's not too far removed
from the static typing debate or people's fascination with making
domain-specific languages.

> A solution would be writing the code with a logging function to begin
> with, alas many times that is out of one's hand. I wished print was a
> function great many times. I bet Guido has had similar experiences,
> note that attempt to keep print in the current form but have it print
> to a file ... with that crazy syntax, print >>f, ... alas that did not
> solve anything

Yes, print >>f is a bit of a hack which I must admit to using
occasionally. However, for every enthusiast of one approach, there
will always be an enthusiast for another (see point #6):

http://mechanicalcat.net/cgi-bin/log/2003/09/02#anti-pitfalls

> It is time to fix it for good.

Well, it has always been possible to use a logging function, just not
one called "print" exactly.

Paul




More information about the Python-list mailing list