5 ms·
> Functions are first-class in python and can be passed as arguments to other functions. I'm not sure I understand what you mean with the above statement. I be
by haikuginger 9y ago
> Functions are first-class in python and can be passed as arguments to other functions. I'm not sure I understand what you mean with the above statement.
I believe the author is referring to inline definition:
setTimeout(function(){alert("Timed out!");}, 5000)
You can do something similar with lambdas in Python, but the allowed syntax is relatively limited compared to a full function definition. You could also define an inline function, but it'd be in a separate statement from the call you make with it. Unfortunately Python doesn't allow for creating and returning a first-class function in a single expression.