0

Please look at my chapp function.

I never called it but it runs formatting decorator

def formatting(lowerscase=False):
    print('called')
    def formatting_decorator(func):
        def wrapper(text=''):
            if lowerscase:
                func(text.lower())
            else:
                func(text.upper())
        return wrapper
    return formatting_decorator

@formatting(lowerscase=False)
def chaap(message):
    print(message)

How can I solve it?

Anshika Singh
  • 994
  • 12
  • 20
CrayZis
  • 1
  • 1
  • 2
    Does this answer your question? [Python Decorators run before function it is decorating is called?](https://stackoverflow.com/questions/341379/python-decorators-run-before-function-it-is-decorating-is-called) – sim Jul 23 '20 at 14:16
  • That's the whole point: decorators _are supposed to_ run before the function is called. In fact, they're run as soon as the function is _defined_. – ForceBru Jul 23 '20 at 15:09

0 Answers0