mixins - add Python standard methods

class repr_from_init[source]

Mixin that implements __repr__ method based in signature of __init__.

Example

>>> from drytools import args2attrs
>>> class my_cls(repr_from_init):
...     @args2attrs
...     def __init__(self, a1, *args, k1=8, k2=8):
...         pass
>>> my_cls(1,2,'foo')
my_cls(1, 2, 'foo')
>>> my_cls(k2=5, a1=1)
my_cls(1, k2=5)

Requirements:

  • __init__ must not have any variable keyword arguments
  • __init__ arguments (including variable positional ones) must all be saved as instance attribtues with the same names. An easy way to do this is to use the args2attrs() decorator.