<commit_before>Decorators
==========

.. decorator:: decorator

    An easy way to create decorators. Here is simple logging decorator::

        @decorator
        def log(call):
            print call._func.__name__, call._args, call._kwargs
            return call()

    ``call`` object also support by name arg introspection and passing additional arguments to decorated function::

        @decorator
        def with_phone(call):
            # call.request gets actual request value upon function call
            phone = Phone.objects.get(number=call.request.GET['phone'])
            # phone arg is added to *args passed to decorated function
            return call(phone)

        @with_phone
        def some_view(request, phone):
            # ... some code using phone
            return # ...

    You can easily create decorators with arguments too::

        @decorator
        def joining(call, sep):
            return sep.join(imap(sep.__class__, call()))

    Usage example shown in :func:`joining` docs.

    You can see more examples in :mod:`flow` and :mod:`debug` submodules source code.<commit_msg>Fixed a pair of typos in decorators docs<commit_after>Decorators
==========

.. decorator:: decorator

    An easy way to create decorators. Here is simple a  logging decorator::

        @decorator
        def log(call):
            print call._func.__name__, call._args, call._kwargs
            return call()

    ``call`` object also supports by name arg introspection and passing additional arguments to decorated function::

        @decorator
        def with_phone(call):
            # call.request gets actual request value upon function call
            phone = Phone.objects.get(number=call.request.GET['phone'])
            # phone arg is added to *args passed to decorated function
            return call(phone)

        @with_phone
        def some_view(request, phone):
            # ... some code using phone
            return # ...

    You can easily create decorators with arguments too::

        @decorator
        def joining(call, sep):
            return sep.join(imap(sep.__class__, call()))

    Usage example shown in :func:`joining` docs.

    You can see more examples in :mod:`flow` and :mod:`debug` submodules source code.
{'fraction_non_alphanumeric': 0.0903905221588416, 'fraction_numerical': 0.0, 'mean_word_length': 2.3333333333333335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '765492', 'n_tokens_mistral': 578, 'n_tokens_neox': 552, 'n_words': 217}