0xA537FD / gen-repr

Lightweigt python (2 & 3) library to generate the __repr__ method of a class.

Home Page:https://pypi.org/project/gen-repr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gen-repr Build Status

Lightweight python library without any dependencies to automatically generate the __repr__ method for any class.

Getting started

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

Example

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')>:

About

Lightweigt python (2 & 3) library to generate the __repr__ method of a class.

https://pypi.org/project/gen-repr/

License:MIT License


Languages

Language:Python 100.0%