gratuitous new features in 2.0
Aahz Maruch
aahz at netcom.com
Fri Aug 25 11:26:49 EDT 2000
In article <cphf89v19d.fsf at cj20424-a.reston1.va.home.com>,
Guido van Rossum <guido at beopen.com> wrote:
>
>When you are considering an extension for the print statement, it's
>not right to add a function or method that adds a new feature in one
>dimension (where the output goes) but takes away in another dimension
>(spaces between items, and the choice of trailing newline or not). We
>could add a whole slew of methods or functions to deal with the
>various cases but that seems to add more confusion than necessary, and
>would only make sense if we were to deprecate the print statement
>altogether.
>
>I feel that this debate is really about whether print should have been
>a function or method rather than a statement. If you are in the
>function camp, of course adding special syntax to the existing print
>statement is not something you like. I suspect the objection to the
>new syntax comes mostly from people who already think that the print
>statement was a bad idea. Am I right?
I've seen at least one person who thinks print-as-statement is a Bad
Idea, but I'm certainly not one of them. I agree that there's something
simple and magical about
>>> print 1+1
2
>>> total = 20
>>> print "Total is:", total
20
for a new programmer. I started out with BASIC, myself, and while I
quickly graduated to and became a convert to Pascal, I think that simple
magic is a necessary ingredient for getting people excited about
programming.
I just think this simple magic should be restricted to new programmers
and -- to a lesser extent -- kept as a convenience for experienced
programmers. I *don't* think it should be made more powerful (and
therefore complicated); while I don't expect it to change, I could make
a case that allowing the trailing comma should never have happened.
I think it is reasonable that non-simple magic require a function call.
In essence, I think I'm applying your principles more rigorously than
you choose to; that's your call, in the end.
But to repeat the point I've made continuously in our private e-mail, I
think it's a Bad Idea to make a change to the core language on such
short notice.
>The first syntax is more Pythonic because it's an extension of an
>existing Python feature. The typical sequence of explanation to a
>newbie would go as follows:
>
> To print data, use "print item, ...". Oh, it goes to a file named
> sys.stdout. If you want it to go elsewhere, e.g. to sys.stderr, use
> this extension: print >>sys.stdout, item, ...".
>
>With any of the function alternatives, this would become:
>
> To print data, use "print item, ...". Oh, it goes to a file named
> sys.stdout. If you want it to go elsewhere, e.g. to sys.stderr, use
> the following completemy different syntax:
> "sys.stdout.writeln(item, ...)".
The problem with this is that it assumes understanding of a "file".
That's more advanced than I see the primary usage of print for.
--
--- Aahz (Copyright 2000 by aahz at pobox.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
The difference between "intelligence" and "wisdom": Londo and G'Kar --Aahz
More information about the Python-list
mailing list