Open ChristophWWagner opened 4 years ago
The function getargspec should do the trick. It also returns the default values. If you use the Python3 interpreter you could also use getfullargspec.
Another interesting use of inspect could be the getmembers, if we want to know the names of certain objects of a given class. It could return all function names, for example.
Good, the code on function name inspection should work based on the data blob of a StepPython
item in the Fridge
. When a StepPython
Item is instantiated, we need to do the following steps:
execute
function and store a reference to this function inside the StepPython
object for execution.chef
for simplicity). All arguments to the step will be passed via keyworded arguments, whose names we need to extract and also store in the StepPython
object as the input
key list.execute
function shall always be a dictionary with name:value mappings. We'll see how we handle this guy exactly when we come to execution handling
FInd out how to detet names of function arguments (key-worded arguments) of python functions.
By using Python's inspect capabilities, a function shall be generated that returns
['bla', 'blub']
for the given example, i.e. the names of the keyworded arguments of an arbitrary function.Final result: A demonstration script is created that contains the function and exhibits correct functionality. Additional capabilities and interesting notes about the inspection framework are documented in the discussion to this issue.