I'm relatively new to python and I was wondering if it's possible to pass one function to another. I have some functions that basically do the same think like:
if(#some condition):
#do something
else:
#do something else
What I want to do is something like this:
def generic_func(self, x, y):
if #somecondition:
#do function x
else:
#do function y
def calls_generic_func(self, key, value):
lambda x: self.list[-1].set(key,value)
lambda y: self.d.set(key,value)
self.generic_func(x,y)
Unfortunately this doesn't seem to work as when I call self.generic_fun(x,y)
I get an error that says global name x
is not defined. Any ideas?