Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Automatically generate the repr of a class with all it's fields

Project description

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"

peter = Person()
peter.first_name = u"Peter"
peter.age = -1

repr(peter) # result: "<Person (first_name='Peter', age=-1)>:

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gen-repr, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size gen_repr-0.2.0-py2-none-any.whl (3.9 kB) File type Wheel Python version py2 Upload date Hashes View hashes
Filename, size gen-repr-0.2.0.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page