Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 740 Bytes

README.md

File metadata and controls

32 lines (25 loc) · 740 Bytes

represent

This library provides a simple way to generate Pythonic string representations of objects.

Usage:

import represent

class Foo:
    def __init__(self, *args, **kw):
        self.args = args
        self.kw = kw

    def __repr__(self):
        return represent.literal(self, *self.args, **self.kw)

class Bar(Foo):
    def __repr__(self):
        return represent.nonliteral(self, *self.args, **self.kw)

if __name__ == '__main__':
    print(Foo(1, 2, 3, a='something', b={})) # Prints `Foo(1, 2, 3, a='something', b={})`
    print(Bar(1, 2, 3, a='something', b={})) # Prints `<Bar 1, 2, 3, a='something', b={}>`

Dependencies:

  • Python 2.7 - 3.x

Installation:

$ python setup.py install