Invoke python callable with an arg list -


simple question: how can pass arbitrary list of args python callable?

let's want invoke function command line, so:

my_script.py foo hello world 

with following script:

import myfuncs f = getattr(myfuncs, sys.args[1]) if f , callable(f):     # bit don't know. want f(sys.args[2:]) 

i'm sure there's way this, must overlooking it.

you looking sequence unpacking. i.e. f(*sys.argv[2:])


Comments

Popular posts from this blog

SAP Web Service from .NET via WCF -

Optimized Line drawing in QT -

datetime - str to time in python -