Imagine I have the following two methods:
def function(self, my_object):
self.things.add(my_object)
def function_args(self, arg1, arg2, arg3 = None):
my_object = MyObject(arg1, arg2, arg3)
self.things.add(my_object)
I would like to write this as a single function that can be called with positional parameters:
something.function(an_object)
something.function(arg1, arg2, arg3)
I can see how to do it if I'm willing to always call the resulting function with keyword arguments, and I can see how to do it if I'm willing to change the signature of the second function to accept a list or tuple of the three arguments, so that each version has single argument and I can differentiate by type (which doesn't seem quite right in Python).
Can I cleanly write a single function that will allow me to call it with either set of positional arguments?