def function(one, two, three): print 'Function called with:', one, two, three # This will work just fine args = [1, 2, 3] function(*args) # This will work just fine, as well args = '456' function(*args) # Call a function with any number of arguments given def call(f, args): # Unpack the list of args and give to the function # The cool thing is that we don't have to know how many arguments # the function takes, we just use the * operator and it unpacks them for us. f(*args) # Pass in our function and arguments args = [7, 8, 9] call(function, args)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question