Skip to main content

A monkey-patch library to provide more compact representation for Stripe objects

Project description

Stripe Repr

A monkey-patch library to provide more compact representation for Stripe objects.

If you ever tried to explore the Stripe API from the console, you did notice that the representation format of the objects is overly verbose. A single call of something like stripe.Customer.list() pollutes the output with hundreds of lines of the output.

To simplify the exploratory work for ourselves, we created a simple stripe_repr library that we install in our development environment. Then we use it as-is:

import stripe_repr

stripe_repr.patch()

The output becomes more manageable:

>>> stripe.Customer.list()
ListObject(data=[Customer(id='cus_HOQHEicZ9WvOJk'), ..., Customer(id='cus_HOG3cB0b8sin1q')])

The second annoyance is date-times, represented in seconds since epoch. Whenever possible, the repr tries to convert them to a proper datetime and format as a string. When it's not enough, you can call a method formatted_dict() that also has a shortcut d().

In  [1]: stripe.Invoice.retrieve('in_xxxxx).d()
Out [1]:
 {'id': 'in_xxxxx',
 'object': 'invoice',
 'account_country': 'US',
 ...
 'created': '2020-06-02T16:58:18',
 'currency': 'usd',
}

Project details


Download files

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

Source Distribution

stripe-repr-1.0.2.tar.gz (3.0 kB view hashes)

Uploaded source

Built Distribution

stripe_repr-1.0.2-py3-none-any.whl (3.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page