I was looking at this line of code -
result = function(self, *args, **kwargs)
And I was not able to find a definition of the function keyword for Python. Could someone link me to the docs and/or explain that this line of code does? I intuitively think I know, but I don't understand why I can't find any docs on it.
In searching through http://docs.python.org both the new module and its successor types seem to have something to do with it.
That's because function is not a python keyword.
If you expand your view just a little, you can see that function is a variable (passed in as a parameter).
def autoAddScript(function):
"""
Returns a decorator function that will automatically add it's result to the element's script container.
"""
def autoAdd(self, *args, **kwargs):
result = function(self, *args, **kwargs)
if isinstance(result, ClientSide.Script):
self(result)
return result
else:
return ClientSide.Script(ClientSide.var(result))
return autoAdd
In this case function is just a formal parameter to the autoAddScript function. It is a local variable expected to have a type that allows you to call it like a function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With