pythonplumbum

Pass parameters to python plumbum command from a list


I'm using Plumbum to run command line utilities in the foreground on Python. if you had a command foo x y z, you would run it from Plumbum like so:

from plumbum import cmd, FG
cmd.foo['x', 'y', 'z'] & FG

In the code I'm writing however, the parameters ['x', 'y', 'z'] are generated into a list. I could not figure out how to unpack this list to send it as parameters to plumbum. Any suggestions?


Solution

  • Turns out I could have used __getitem__ for this. All I had to do was:

    from plumbum import cmd, FG
    params = ['x', 'y', 'z']
    cmd.foo.__getitem__(params) & FG