This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!
Project Description

This module exposes a few functions and a class decorator to make the task of writing __repr__() and __str__() for custom classes much easier. It will display a list of nicely formatted (attr, val) pairs with custmizable separator and formatting for each pair.

Let’s look at an example:

from rr import pretty

class foo(object):
    __str__ = pretty.str
    __repr__ = pretty.repr
    __info__ = pretty.info(["x", "y", "z"])

    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z

f = foo(1, 2, 3)
print repr(f)  # see for yourself :)
print str(f)

Now, let’s do the same, only this time we’ll use the klass() class decorator:

from rr import pretty

@pretty.klass
class foo(object):
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z

f = foo(1, 2, 3)
print repr(f)  # see for yourself :)
print str(f)

We even left out the attribute list, and pretty.info() (which is what pretty.klass() uses behind the scenes) builds it for us. That’s it! You get nice __repr__() and __str__() methods for free.

Installation

>From PyPI (“stable” release):

pip install rr.pretty

>From the Git repo:

git clone https://github.com/2xR/rr.pretty.git
pip install ./rr.pretty

Contributing

Contributions are welcome through github pull requests (tests would be nice to have… :P)

And if you’re using the library and would like to say “thanks!” and/or keep me working on it, why not buy me a beer?

Release History

Release History

0.1.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
rr.pretty-0.1.0-py2-none-any.whl (6.5 kB) Copy SHA256 Checksum SHA256 py2 Wheel Jun 24, 2016
rr.pretty-0.1.0.zip (7.8 kB) Copy SHA256 Checksum SHA256 Source Jun 24, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting