On Fri, Sep 18, 2009 at 01:30:31PM +0100, Michael Hanselmann wrote:
> 2009/9/18 Iustin Pop <[email protected]>:
> > --- a/scripts/gnt-instance
> > +++ b/scripts/gnt-instance
> > +def _ManyOpsWrapper(operation):
> > +  def wrap(fn):
> > +    def realfn(opts, args):
> > […]
> > +      return 0
> > +    return realfn
> > +  return wrap
> 
> This wrapper changes the result value of the wrapped function and it's
> not very obvious. Can you maybe write it a more expressive way?
> 
> def _StartInstance(name, opts):
>   return opcodes.OpStartupInstance(…)
> 
> def GetManyOperations(fn, operation):
>   def manyops(…):
>     …
>     op = fn(…)
>     …
>     return 0
>   return manyops
> 
> commands = [(…, GetManyOperations(_StartInstance, "startup"), …)…]

Good point - I hate decorators with arguments which require two internal
wrapper functions…

Will resend.

iustin

Reply via email to