More like a shell command.

Mike Driscoll kyosohma at gmail.com
Wed Aug 6 11:33:33 EDT 2008


On Aug 6, 9:38 am, Bill <galaxyblu... at gmail.com> wrote:
> Is there anyway I can extend python to accept a command
> which looks more like shell syntax than a function call.
>
> I want to be able to do this:
>
>     if blah :
>         MyCommand  Arg1  Arg2
>
> as opposed to this:
>
>     if blah :
>         MyCommand(Arg1,Arg2)
>
> or this:
>
>     if blah :
>         x("MyCommand  Arg1  Arg2")
>
> Of source, I would like to do this by writing a module (or through
> some other run-time hook) as opposed to editing the Python source
> code.
>
> Thanks in advance
> (unless you are just a Python nut who is flaming to tell me that I
> should not want this.  :-)  )
>
> Bill

I'm not aware of any way to do this without modifying the original
source in some fundamental way. You may be able to use some
metaprogramming techniques, like decorators, to achieve this, although
I'm not thinking of anything clever at the moment.

-------------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org
Python Extension Building Network:     http://www.pythonlibrary.org



More information about the Python-list mailing list