I want to create a function that would behave differently depending on how the input is passed to it.
For example:
def my_func(a):
if is_constant_input(a): # Does something like this conditional exist?
print(f"A constant input {a} was passed")
else:
print(f"A variable input {a} was passed")
then I call the function in two ways.
First way:
val = [1, 2, 3]
my_func(val) # A variable input [1, 2, 3] was passed.
Second way:
my_func([1, 2, 3]) # A constant input [1, 2, 3] was passed.
I want to know if there's a way to implement that is_constant_input()
conditional?
EDIT: fixed the example by using an mutable argument (e.g., a list
)