Reputation: 754
Currently I have around 5 functions where I use a common code. I was trying to keep this common code as a function and call in these 5 functions.
This will be my common function:
def commonfunc(key):
do something
These are kind of my other 5 functions where I use this common code. To change something I have to edit all my 5 functions. I am looking to call this common function in these 5 common functions.
def func1(request)
do something...
commonfunc(key)
do something....
return httpsresponse(request,.....)
In this code everything works till second line. Thereafter it does not comeback to func1 and do rest of things.
What I am missing?
Upvotes: 1
Views: 48
Reputation:
Yes, you can definitely do that. If you want to comeback to func1, you can return something from the commonfunc and accept it in the func1.
def commonfunc(key):
# Do something..
return something
and in the func1..
def func1(request)
# do something...
s = commonfunc(key)
# do something....
return httpsresponse(request,.....)
Upvotes: 1