Thinking about "print >>"
Arno Paehler
paehler at gol.com
Mon Sep 18 13:59:22 EDT 2000
talking about Fortran, how about 'print' and 'write', i.e.
print something goes to sys.stdout
write file, something goes to file
think this is (sort of) standard Fortran,
C'ish fprint isn't bad either, but at least 'print >>'
probably is better than C++ (was that cout << or cout >>,
C++ is quite-counterintuitive here I think)
"Michael D. Marchionna" wrote:
>
> 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://sourcefo
> > rge.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