Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You mean something like:

  class FancyDecorator():
      __init__(self, *args):
          self.args = args
  
      __call__(self, fn):
          return decorate_fn_with_args(fn, self.args)
  
  dec = FancyDecorator(42)
  
  @dec
  def foo():
      pass
  
  @FancyDecorator(41)
  def bar()
      pass
Might have it wrong since I haven't messed with decorators in a while and they aren't exactly what one would call simple.

--edit--

code formatting is all wonky so...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: