I am wiriting a script in which I would like to verify if a given argumente to a function is itself a function. I have checked in the IDLE the type()
of that argument.
Let us assume that the argumente is called a
and that I know that a
is a function.
When I type type(a)
in the Shell, this gets printed:
<class 'function'>
But if I try to type this:
type(add) == function
It gives me a NameError: name 'function' is not defined
(That was not my only attempt, but if I put them all here this will get too long)
I think I understand that part, because I think function
is not a keyword like int
or float
, which lets me do conditionals like type(3) == int
But, knowing this, how can I check if something is from a given built-in type, if that type does not have a specific keyword (or maybe, those keywords are not that well-known)
Thanks in advance.