Are Python Decorators the same or similar, or fundamentally different to Java annotations or something like Spring AOP, or Aspect J?
I use both of them in a similar way: to turn on/off debugging or testing options.
For example (Python decorators):
def measure_time(func):
def _measure_time(*args, **kwargs):
t0 = time.time()
ret = func(*args, **kwargs)
print "time=%lf" % (time.time()-t0)
...
return ret
return _measure_time
@measure_time
def train_model(self):
...
For Java annotations, use getAnnotation, etc. can do the similar jobs or more complicated ones.