Module tk_steroids.routines
Functions
def extend_keywords(keyword_source)
-
Function decorator to extend signature about keyword arguments of a function using keywords of another function.
Useful when you have a wrapper function with **kwargs that get directly passed to another function, and you want to use inspecting on the wrapper function and gain the keyword arguments of the inner function as well.
Example usge:
@extend_keywords(hidden_function) def wrapping_function(x, a=1, **kwargs): ... in_between_results = hidden_function(things, **kwargs) ... return something # now using inspect.signature on wrapping function contains also # the keywords arguments of the inner fucntion
Arguments
keyword_source
:callable
- The source function, which's kws are added to the decorated function.
def inspect_booleans(function_or_method, exclude_keywords=[])
-
Inspect and get boolean default keyword arguments from a live function to be used in TickboxFrame.
Arguments
function_or_method
:callable
- An callable on which we apply inspect.signature
exclude_keywords
:list
ofstrings
- Keyword arguments to be excluded by their name.
Returns
options
,defaults
:list
- Keyword argument names (string) and their default values (bool). See TickboxFrame for documentation.
def inspect_types(types, function_or_method, exclude_keywords=[], exclude_types=())
-
Retrieve keyword arguments of the given types
Inspect and get the default keyword arguments of the given types from a live function to be used in TickboxFrame.
Arguments
types : class or tuple The keyword arguments of having default of these types to be returned function_or_method : callable An callable on which we apply inspect.signature exclude_keywords : list of strings Keyword arguments to be excluded by their name. exclude_types : tuple of types Types to exclude
Returns
options
,defaults
:list
- Keyword argument names (string) and their default values (bool). See TickboxFrame for documentation.