gratuitous new features in 2.0

Aahz Maruch aahz at netcom.com
Sat Aug 26 10:52:23 EDT 2000


In article <cphf8858vd.fsf at cj20424-a.reston1.va.home.com>,
Guido van Rossum  <guido at beopen.com> wrote:
>
>    def table(n):
>	for j in range(1, n+1):
>	    for i in range(1, n+1):
>		print i, 'x', j, '=', i*j
>	    print
>
>Now you are asked to make it print to another file -- a standard
>example of how software typically is asked to evolve.
>
>The new print syntax makes this a straightforward change:
>
>    import sys
>
>    def table(n, file=sys.stdout):
>	for j in range(1, n+1):
>	    for i in range(1, n+1):
>		print >>file, i, 'x', j, '=', i*j
>	    print >>file

While your example has moved me closer to your viewpoint, I still think
the following example isn't much more onerous:

    import sys
    from sys import println

    def table(n, file=sys.stdout):
	for j in range(1, n+1):
	    for i in range(1, n+1):
		println( file=file, i, 'x', j, '=', i*j )
	    println(file=file)
--
                      --- 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