alligator.utils¶
-
alligator.utils.
determine_module
(func)¶ Given a function, returns the Python dotted path of the module it comes from.
Ex:
from random import choice determine_module(choice) # Returns 'random'
Parameters: func (callable) – The callable Returns: Dotted path string Return type: str
-
alligator.utils.
determine_name
(func)¶ Given a function, returns the name of the function.
Ex:
from random import choice determine_name(choice) # Returns 'choice'
Parameters: func (callable) – The callable Returns: Name string Return type: str
-
alligator.utils.
import_attr
(module_name, attr_name)¶ Given a dotted Python path & an attribute name, imports the module & returns the attribute.
If not found, raises
UnknownCallableError
.Ex:
choice = import_attr('random', 'choice')
Parameters: - module_name (str) – The dotted Python path
- attr_name (str) – The attribute name
Returns: attribute
-
alligator.utils.
import_module
(module_name)¶ Given a dotted Python path, imports & returns the module.
If not found, raises
UnknownModuleError
.Ex:
mod = import_module('random')
Parameters: module_name (str) – The dotted Python path Returns: The imported module Return type: module