Skip to main content

PyPI Version Python Version MIT License

Installation

$ pip install represent

Automatic Generation

from represent import ReprMixin


class Rectangle(ReprMixin, object):
    def __init__(self, name, color, width, height):
        self.name = name
        self.color = color
        self.width = width
        self.height = height

        super(Rectangle, self).__init__()

rect = Rectangle('Timothy', 'red', 15, 4.5)
print(rect)
Rectangle(name='Timothy', color='red', width=15, height=4.5)

Declarative Generation

from represent import ReprHelper


class ContrivedExample(object):
    def __init__(self, description, radians, shape, color, miles):
        self.description = description
        self.degrees = radians * 180 / 3.141592654
        self.shape = shape
        self._color = color
        self.km = 1.60934 * miles

    def __repr__(self):
        r = ReprHelper(self)
        r.positional_from_attr('description')
        r.positional_with_value(self.degrees * 3.141592654 / 180)
        r.keyword_from_attr('shape')
        r.keyword_from_attr('color', '_color')
        r.keyword_with_value('miles', self.km / 1.60934)
        return str(r)

ce = ContrivedExample('does something', 0.345, 'square', 'red', 22)
print(ce)
ContrivedExample('does something', 0.345, shape='square', color='red', miles=22.0)

For pretty printer support and more information, visit the documentation!

Release files for Represent 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Represent 1.2.1
File Size Uploaded
Represent-1.2.1.tar.gz 5.8 kB Details

Release files / Represent-1.2.1.tar.gz

Download URL Represent-1.2.1.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
acf8daadd7e96882282deb43fe55d050867722753fd80a3572b693b0d6f0f2ad
BLAKE2b-256 checksum
How to use checksums
031a19f2da154e99b9fd867439a81f4349b2c509d183012089247d58f399bb81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

2.2.0

2 release files

2.1

2 release files

2.0

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

1 release file

This release

1.2.1 This release

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0

1 release file

1.0.0.dev0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page