Interpolation (was: Keyword calling gotcha ?)

Jim Meier fatjim at home.com
Fri May 28 17:24:21 EDT 1999


Greg Ewing wrote:
> 
> Marko Schulz wrote:
> >
> > It would be nice to have a way of interpolating sequences in parameter
> > lists.
> 
> I'd like to be able to write
> 
>         foo(a, b, c, *arglist, **kwdict)
> 
> as a function call.

I like this syntax too. I've been wanting to play with Python's syntax
for a while now, so I thought I'd give it a try. (Note: I'm not a
Parser-Pro. If you know what you're doing and would like to see this
done, best to do it yourself and not wait for me.. :)


I took a (very) quick stab at sticking this into the grammar file
(Grammer/Grammar), but have no idea where to go from there. The
Tokenizer/Parser sources seem large and daunting - could anyone give me
a roadmap before I drown myself? I have played with Bison./YACC and made
some working, useable toy languages, but this seems to be very
different.

oh, this is how I changed  Grammar/Grammar:

(at the very end:)
arglist:  argument (',' argument)* [',']
argument: [test '='] test       # Really [keyword '='] test

becomes:
arglist:  argument (',' argument)* ['*' NAME [('*'|'*' '*') NAME]]
[('**'|'*' '*') NAME]

is there a more sensible way to do this?


-- 
...
You know it's time to rethink your design when you can't debug your
#defines.
-Jim.




More information about the Python-list mailing list