[Python-ideas] 'where' statement in Python?

George Sakkis george.sakkis at gmail.com
Thu Jul 22 22:49:29 CEST 2010


On Thu, Jul 22, 2010 at 10:21 PM, geremy condra <debatem1 at gmail.com> wrote:

> I would also argue that the more valid comparison would be nested functions
> or classes- both perfectly pretty constructs on their own- which would cause
> me to gnaw on otherwise unoffending office furniture if I encountered them
> nested 3 deep.

I guess you're not much fond of decorators then; it's common to define
them exactly as 3-level deep nested functions:

def decofactory(deco_arg):
     def decorator(func):
        def wrapper(*args, **kwargs):
            if deco_arg:
               return func(*args, **kwargs)
        return wrapper
    return decorator

@decofactory(n)
def func(x, y):
    ...

George



More information about the Python-ideas mailing list