pg.patch_on_member

Accessible via pg.patch_on_member, pg.patching.patch_on_member.

patch_on_member(src, cls, name, value=None, value_fn=None, skip_notification=None)[source]

Recursively patch values that are the requested member of classes.

Example:

d = pg.Dict(a=A(x=1), b=2)
print(pg.patching.patch_on_member(d, A, 'x', 2)
# {a=A(x=2), b=4}
Return type:

Any

Parameters:
  • src – symbolic value to patch.

  • cls – In which class the member belongs to.

  • name – Member name.

  • 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.