Thinking about "print >>"

Michael D. Marchionna tralfaz at pacbell.net
Sat Sep 9 17:03:59 EDT 2000


Wouldn't it just plain be simpler to create a new builtin with a different
name that takes a file object as its first argument.  Just call it 'fprint', or
'printf', or 'fprintf', or even 'format' for FORTRAN nostalgia sake.  Any of
these would accomplish the goal without the pointless syntax games.

This is the first time I've run across a python idiom that I truly find
embarassing.

--MDM


William Carrel wrote:

> Just to further beat a dead horse... I've submitted a patch to SourceForge which
> corrects the currently perl like syntax for printing to a file.
>
> The syntax accepted by the patch is as follows:
>
> print [to <file> [,]] [<item> (item ',')* [,]]
> i.e.
> print to sys.stderr "Spammity spam, glorious spam!"
>
> The comma after the 'to file' portion to make the following construct work:
> print to file, []
>
> Since "print to file []" is a vain attempt to index the list/dict 'file'.
>
> The patch is at
> http://sourceforge.net/patch/?func=detailpatch&patch_id=101439&group_id=5470
>
> No, 'to' is not treated as a keyword elsewhere.  Yes, if you have a variable
> named 'to' its value is unaffected by this, and it should matter anyway since
> if you wanted to print to and something else, you'd use "print to, file,".
>
> And hopefully someone will give it a look over I think the syntax is much more
> consistant with the overall spirit of Python than this hackish looking
> rightshift stuff.
>
> --
>  Andy Carrel
>  CVS Repo-man ** Go2Net Web Operations Group
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20000909/7e98840a/attachment.html>


More information about the Python-list mailing list