Lightweight python library without any dependencies to automatically generate
the __repr__
method for any class.
Install this package throught pip
$ pip install gen-repr
After that you can import it in your program like this
from genrepr import gen_repr
from genrepr import gen_repr
@gen_repr()
class Person(object):
def __init__(self):
self.first_name = u""
self.age = 0
self._hair = u"any color you like"
self._location = u"localhost"
@property
def location(self):
return self._location
peter = Person()
peter.first_name = u"Peter"
peter.age = -1
repr(peter) # result: "<Person (first_name='Peter', age=-1, location='localhost')>: