pg.patch_on_type¶
Accessible via pg.patch_on_type
, pg.patching.patch_on_type
.
- patch_on_type(src, value_type, value=None, value_fn=None, skip_notification=None)[source]¶
Recursively patch values on matched types.
Example:
d = pg.Dict(a={'x': 1}, b=2) print(pg.patching.patch_on_type(d, int, value_fn=lambda x: x * 2)) # {a={x=2}, b=4}
- Return type:
- Parameters:
src – symbolic value to patch.
value_type – Value type to match.
value – New value for field that satisfy condition.
value_fn – Callable object that produces new value based on old value. If not None, value must be None.
skip_notification – If True, on_change event will not be triggered for this operation. If None, the behavior is decided by pg.notify_on_rebind. Please see symbolic.Symbolic.rebind for details.
- Returns:
src after being patched.