Q:

Force function caller decide which default value is used

Lets say I have the following function:
def myFun(a=None, b=None):
    print a, b

Now I call the function:
myFun("hi") # Case 1
>>>hi None

myFun(b="hi") # Case 2
>>>None hi

myFun(a="hi") # Case 3
>>>hi None

Is there a way to throw an exception if the function caller did not decide which variable the value "hi" is assigned to? That means I would like to have an exception in the 1st case but not in the 2nd and 3rd case. I use python 2.7.

A:

In Python3 you can specify keyword-only arguments:
def myFun(*, a=None, b=None):
    print(a, b)

myFun('hi')

raises 
TypeError: myFun() takes 0 positional arguments but 1 was given

In Python2, as Ricardo Silveira points out you could use **kwargs to force all arguments to be keyword arguments.
def myFun(**kwargs):
    a, b = kwargs.get('a'), kwargs.get('b')
    print(a, b)

myFun('hi')
# TypeError: myFun() takes exactly 0 arguments (1 given)

