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 (function) – The callable |
---|---|
Returns: | Dotted path string |
Given a function, returns the name of the function.
Ex:
from random import choice
determine_name(choice) # Returns 'choice'
Parameters: | func (function) – The callable |
---|---|
Returns: | Name string |
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: |
|
---|---|
Returns: | attribute |
Given a dotted Python path, imports & returns the module.
If not found, raises UnknownModuleError.
Ex:
mod = import_module('random')
Parameters: | module_name (string) – The dotted Python path |
---|---|
Returns: | module |