Re:Why Python?
by ekiru on Saturday October 23, 2010 @03:00AM
(#1822880)
How is this so? Decorators are just syntactic sugar for defining a function then replacing it with the result of calling another function (the decorator) on it.
[ Parent
| on HN ]
Re:Why Python?
by miloshasan on Saturday October 23, 2010 @03:27AM
(#1822920)
The decorator can do introspection on the function object. This project uses the idea to execute (some) Python code on the GPU:
> The decorator can do introspection on the function object.
so can normal (i.e. not using decorators) code after the the function, e.g.:
def myFunction(x):
blah
doSomethingWith(myFunction)
Here, doSomethingWith() can introspect on myFunction()
Re:Why Python?
by miloshasan on Saturday October 23, 2010 @06:39PM
(#1824558)
Ah, yes - of course decorators do not fundamentally increase the expressive power of the language (and neither do lambdas, obviously). It's all just a matter of convenience and elegance, which are in the eye of the beholder anyway...
Re:Why Python?
by JeremyBanks on Saturday October 23, 2010 @03:51AM
(#1822948)
Which being able to wrap the function definition in a function call could accomplish. Unfortunately that's not the direction the Python team wants to take the language.