Skip to main content

Print with auto indentation

Project description

prindent

Python module to print with automatic indentation

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

You can also pass a custom string for indentation:

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.0.tar.gz (14.3 kB view hashes)

Uploaded Source

Built Distribution

prindent-1.0.0-py3-none-any.whl (14.3 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