def get_item( l:Sequence, # Sequence to get item of i:int, # Index of item to get default:Optional=None, # Default value to return if sequence does not contain item at index)->Any: # Item or default value
Return item at index i from sequence l or default if item does not exist.
get_item('abc', 1)
'b'
get_item('abc', 4, "foo")
'foo'
str(get_item('abc', 4))
'None'
filter_args
def filter_args( fnc:Callable, # Function to test keyword arguments against kwargs:VAR_KEYWORD)->dict: # Keyword arguments defined in signature of `fnc`
Return only keyword arguments defined in signature of function fnc.
filter_args(get_item, default=3, foo='bar')
{'default': 3}
filter_out_args
def filter_out_args( fnc:Callable, # Function to test keyword arguments against kwargs:VAR_KEYWORD)->dict: # Keyword arguments not defined in signature of `fnc`
Return only keyword arguments not defined in signature of function fnc.