Skip to content

Commit 8f2a5e2

Browse files
author
morvanabonin
committed
Packing Python
1 parent c5316f2 commit 8f2a5e2

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

packing.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Call normal of date function passing three parameters - year, month, day
2+
from datetime import date
3+
d = (2013, 3, 15)
4+
print (date(d[0], d[1], d[2]))
5+
6+
#Function date using packing to pass - year, month, day
7+
from datetime import date
8+
d = (2013, 3, 15)
9+
print (date(*d))
10+
11+
#Other example using a dictionary data.
12+
def new_user(active=False, admin=False, root=False):
13+
print(active)
14+
print(admin)
15+
print(root)
16+
17+
config = {"active" : False,
18+
"admin" : True,
19+
"root" : False}
20+
21+
new_user(config.get('active'), config.get('admin'), config.get('root'))
22+
23+
print ('Function using packing args')
24+
def new_user(active=False, admin=False, root=False):
25+
print(active)
26+
print(admin)
27+
print(root)
28+
29+
config = {"active" : False,
30+
"admin" : True,
31+
"root" : True}
32+
33+
new_user(**config)

0 commit comments

Comments
 (0)