Checking that arguments are compatible with a function without running it
Python allows to check that a set of arguments is compatible with a function without having to actually run the function:
>>> from inspect import signature
>>>
>>> def my_function(a, b, foo=None):
... pass
...
>>> signature(my_function).bind(1, 2, foo='bar')
<BoundArguments (a=1, b=2, foo='bar')> # No exception
>>> signature(my_function).bind(1, foo='bar')
TypeError: missing a required argument: 'b'
This is very useful for distributed task queues because often the machine that schedules the background job is not the same that executes it. I use it in Spinach to prevent scheduling of jobs which are sure to fail because workers would not be able to execute them.