Usually you'd either define two different functions, or do something like:
def foo(x, y = None):
if y is None:
x, y = x.x, x.y
# do something at position (x, y)
The option to define two different functions seems unwieldy if you're used to languages that have overloading, but if you're used to languages like Python or C that don't, then it's just what you do. The main problem with the above code in Python is that it's a bit awkward to document the first parameter, it doesn't mean the same in the two cases.
Another option is to only define the version of foo
that takes a pos, but also supply a type for users:
Pos = collections.namedtuple('Pos', 'x y')
Then anyone who would have written foo(x,y)
can instead write foo(Pos(x,y))
. Naturally there's a slight performance cost, since an object has to be created.