Possible Duplicate:
How to get the original variable name of variable passed to a function
Is there something like below in python where based on the name of the parameter passed to a function we can execute conditional statements like below.
def func(a,b,c,d)
if fourth paramter = d:
#code
elif fourth parameter = e:
#code
else:
#code
def main():
func(a,b,c,d)
func(a,b,c,e)
You should use keyword arguments:
This is not exactly equivalent to what you want, though. If you want to ensure that
doreis the fourth parameter, that would be more troublesome.Then you could try something like:
Note that this is not exactly what you’re asking. It will not access the “original” name of the variable passed to the function as a positional argument, as in the question linked by Stuart. You shouldn’t even try to do that, it’s pointless.