How to use the makefun.main.wraps function in makefun

To help you get started, we’ve selected a few makefun examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github smarie / python-makefun / makefun / View on Github external
    @wraps(f, new_sig=new_sig)
    def partial_f(*args, **kwargs):
        # since the signature does the checking for us, no need to check for redundancy.
        gen = f(*chain(preset_pos_args, args), **kwargs)
        _i = iter(gen)  # initialize the generator
        _y = next(_i)  # first iteration
        while 1:
                _s = yield _y  # yield the first output and retrieve the new input
            except GeneratorExit as _e:  # ---generator exit error---
                    _m = _i.close  # if there is a close method
                except AttributeError:
                    _m()  # use it first