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

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -