Decorater inside a function? Is there a way?

George Sakkis gsakkis at rutgers.edu
Sun Apr 3 04:20:32 EDT 2005


Yes, it is possible to turn off type checking at runtime; just add this
in the beginning of your define:

def define(func):
    if not ENABLE_TYPECHECKING:
        return lambda func: func
    # else decorate func

where ENABLE_TYPECHECKING is a module level variable that can be
exposed to the module's clients. In my module, the default is
ENABLE_TYPECHECKING = __debug__.


George




More information about the Python-list mailing list