print """ First review the basics of tuples and their expressivity in python""" b, c, d = a = 1, 2, 3 print a, b, c, d ############### print """ How do args and kwargs work? Let's see... (Pay close attention to the structures printed.)""" def some_func(fargs, *args, **kwargs): print fargs print args print kwargs some_func("blah", 1, 2, 3, this=4, that=5) ############### print """ the * will unpack our tuple for us""" my_tuple = (2, 4, 6) print max(*my_tuple) ############### print """ similarly ** unpacks dictionaries""" def defaults_function(this=7, that=9): print this, that my_dict = {'this':4, 'that':5} defaults_function(**my_dict)
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