How about "print file=yonder, yo, de, do"

Jeff Petkau jpet at eskimo.com
Wed Sep 6 02:03:27 EDT 2000


Martin von Loewis <loewis at informatik.hu-berlin.de> wrote in message
news:p6q7l8qonam.fsf at informatik.hu-berlin.de...
> "Jeff Petkau" <jpet at eskimo.com> writes:
>
> > One more random stab at a different syntax, just
> > because this dead horse ain't been flogged enough.
> >
> > How about this syntax:
> >
> >     print file=myfile, 1, 2, 3
>
>...
> The problem is that the parser can't tell. It's a recursive-descent
> parser, which has to decide on an action when it sees 'file'. It can't
> know whether this NAME token is the beginning of the special file
> syntax, or part of an expression, like
>
>       print file==myfile,1,2,3
>
> would be.

Not so, because '=' cannot be part of an expression. The
same syntax is already used for keyword arguments, so it's a bit
silly to claim the parser can't handle it.

Unfortunately it's not totally symmetric with keyword args; that
would place the keyword to go at the end ("print 1,2,file=myfile")
which would break the trailing comma. Sigh.

--Jeff (who used the print >>file thing today and discovered it
wasn't so awful after all, although a coworker thought it looked
like perl)






More information about the Python-list mailing list