Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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.
kwargs.update(preset_kwargs)
gen = f(*chain(preset_pos_args, args), **kwargs)
_i = iter(gen) # initialize the generator
_y = next(_i) # first iteration
while 1:
try:
_s = yield _y # yield the first output and retrieve the new input
except GeneratorExit as _e: # ---generator exit error---
try:
_m = _i.close # if there is a close method
except AttributeError:
pass
else:
_m() # use it first