Skip to content

Commit df1c091

Browse files
author
morvanabonin
committed
Unpacking Python
1 parent 8f2a5e2 commit df1c091

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

unpacking.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#Unpacking Python
2+
3+
#Example using *args
4+
def unpacking_experiment(*args):
5+
arg1 = args[0]
6+
arg2 = args[1]
7+
others = args[2:]
8+
print(arg1)
9+
print(arg2)
10+
print(others)
11+
12+
unpacking_experiment(1, 2, 3, 4, 5, 6)
13+
14+
#Other example using **kwargs
15+
def unpacking_experiment(**kwargs):
16+
print(kwargs)
17+
18+
unpacking_experiment(named="Test", other="Other")
19+

0 commit comments

Comments
 (0)