Skip to main content

Print with auto indentation

Project description

prindent

Python module to print with automatic indentation

Sometimes it is useful to print with indentation to better visualize the data. This is particularly true when multiple for loops and if statements are nested. prindent can automatically indent everything for you.

Usage

from prindent import prindent

prindent('first loop')
for i in range(2):
    prindent('i:', i)
    prindent('second loop')
    for j in range(2):
        prindent('j:', j)
        if j == 1:
            prindent('j=1')

# first loop
#     i: 0
#     second loop
#         j: 0
#         j: 1
#             j=1
#     i: 1
#     second loop
#         j: 0
#         j: 1
#             j=1

prindent supports custom indentation strings:

if True:
    if True:
        for i in range(2):
            prindent('Custom indent', indent='---> ')

# ---> ---> ---> Custom indent
# ---> ---> ---> Custom indent

prindent handles multiple lines:

if True:
    prindent('String\nwith\nnewline')

#     String
#     with
#     newline

prindent accepts multiple args and kwargs just like print():

if True:
    prindent('first', 'second', end='$')

#     first second$

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

prindent-1.0.1.tar.gz (14.4 kB view hashes)

Uploaded Source

Built Distribution

prindent-1.0.1-py3-none-any.whl (14.4 kB view hashes)

Uploaded Python 3

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