Previous topic

Propy (propy)

Next topic

propy.enum_property

This Page

propy.repr_method

propy.repr_method(*args)[source]

A convenience wrapper for creating class __repr__ methods. If ‘__all__’ is passed to the method, all properties assigned to the object will be included in returned string.

Parameters:
args

Strings corresponding to class properties to be returned.

Examples

>>> class Test():
...     __repr__ = repr_method('x', 'y', 'z')
...
...     def __init__(self):
...         self.x, self.y, self.z = 1, 2, 3
...
>>> repr(Test())
'Test(x=1, y=2, z=3)'