Aug-25-2019, 02:50 PM
I'm working on an interface where the user selects functions. But some of those functions are meta-functions that create the function you want. But the meta-functions can have different types of parameters. How do I validate them? The parameter names are pretty consistent, so I can base the validation off the parameter names. But how do I get the parameter names?
Now, because of the way I write my docstrings, I could write something to parse func.__doc__ and return the parameter names. But is there a way to get that information straight from the function object? It turns out there is:
Now, because of the way I write my docstrings, I could write something to parse func.__doc__ and return the parameter names. But is there a way to get that information straight from the function object? It turns out there is:
func.__code__.co_varnames[:func.__code__.co_argcount]I love Python.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures