jasily/lang/with_any.py
def with_it(obj):
    '''
    wrap `with obj` out of func.

    example:

    ``` py
    @with_it(Lock())
    def func(): pass
    ```
    '''

    def _wrap(func):

        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            with obj:
                return func(*args, **kwargs)

        return wrapper

    return _wrap
def with_it(obj):
    '''
    wrap `with obj` out of func.

    example:

    ``` py
    @with_it(Lock())
    def func(): pass
    ```
    '''

    def _wrap(func):

        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            with obj:
                return func(*args, **kwargs)

        return wrapper

    return _wrap
def with_it ( obj ) : def _wrap ( func ) : @ functools . wraps ( func ) def wrapper ( * args , * * kwargs ) : with obj : return func ( * args , * * kwargs ) return wrapper return _wrap
wrap `with obj` out of func.

    example:

    ``` py
    @with_it(Lock())
    def func(): pass
    ```
wrap with obj out of func .