What about:
x,y = nontest() or (None,None)
If nontest returns a tuple of two elements, as it should be, then x and y are assigned to the elements in the tuple. Otherwise, x and y are each assigned to none. The disadvantage of this is that you cannot run special code if nontest returns empty (the above answers may help you if that is your goal). The surface is that it is clean and easy to read / maintain.
source share