Thinking about "print >>"
William Carrel
williamc at go2net.com
Thu Sep 7 00:02:12 EDT 2000
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
More information about the Python-list
mailing list