-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestfile.py
65 lines (42 loc) · 1.63 KB
/
testfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
def func1(arg1, arg2, **kwargs):
print("I am func1 ", arg1, arg2)
def func2(arg21, arg22, **kwargs):
print(" I am func2", arg21, arg22)
FUNC_MAP = {
"func1": func1,
"func2": func2
}
some_arguments = {"arg1": 1, "arg2": 2, "arg21": 3, "arg22": 4}
FUNC_MAP["func1"](**some_arguments)
FUNC_MAP["func2"](**some_arguments)
# run this file now yeah, got it ?
sir samajh toh aaya kaise kiya
pr aisa hua kaise?
I mean maine kbhi aisa kuch nii pda
Its easy.
Think of the functions like a reference, now you already know that we have two types of arguments,
keyword and positional,
now lets say we have a dict of some arguments..
some_arguments = {"arg1": 1, "arg2": 2, "arg21": 3, "arg22": 4}
^ this one
and we know the function name as well eg. func1, func2..
then if we unpack this dictionary with the function's reference it would be passed like this
func1(arg1=1, arg2=2, arg21=3, arg22=4) # func1 only consumes arg1 and arg2 so we need something to capture the rest of the arguments
func2(arg1=1, arg2=2, arg21=3, arg22=4)# func2 only consumes arg21 and arg22 so we need something to capture the rest of the arguments
# thats why we put **kwargs
makes sense ? there ?
yes sir, yes sir totally
mere liye new tha yeh toh isiliye nii smjha tha main
but sir not lets say that yeh dono functions yha nii hote
toh yha pr
FUNC_MAP = {
"func1": func1,
"func2": func2
}
func1 not defined aata naa??
yeah definitely
Okay just to give you a hint about where did I adopt this idea from.
go to urls.py
siarn any ony e
any urls.py
yes sir I am there in jira folder urls.py