Naked function call syntax

Bengt Richter bokr at accessone.com
Sun Jul 15 18:49:04 EDT 2001


On Sat, 14 Jul 2001 17:07:11 -0500, Skip Montanaro <skip at pobox.com> wrote:
[...]
>
>Yesterday I posted a subclass of code.InteractiveConsole that when an
>attempt at evaluating user input failed, it would pass the line to
>os.system:
>
>    http://groups.google.com/groups?q=mycode.py+skip%40pobox.com&hl=en&safe=off&rnum=1&ic=1&selm=mailman.994974802.14320.python-list%40python.org
>
>You could instead have it convert
>
>    foo arg1 arg2 arg3
Actually, I don't mind commas - they don't require the shift key,
so they're about as easy as spaces, and I was thinking of syntax
just like print's anyway ;-)
>
>into 
>
>    foo(arg1,arg2,arg3)
>
>with appropriate argument quoting (checking for ints, strings and such) and
>eval that.  Obviously, if arg2 contained whitespace, you'd have to quote it.
>Completion of this idea is left as an exercise for the reader.
>
Thanks, I'll have a look.
BTW, though, passing eval failures unconditionally to os.system seems a little dangerous,
if that's what you are doing? Maybe I'll add a dictionary of leading names like 'rm'
that would trigger 'are you sure?' if I want to use it for os.system ;-)

But of course what I really want is to play in Tim and Guido's sandbox ;-)

I just managed to put together a pgen.dsp on win32 to build pgen (there didn't seem
to be one in the otherwise beautifully set up workspace/projects). pgen regenerated
the indentical grammar.c and .h, so I guess it's working. Anticipating more fun ;-)
This change should be easier than a multi-statement lambda, I think, depending on
how cleanly newlines are handled.



More information about the Python-list mailing list