Skip to main content

Dynamic left pad creator

Project description

Left-pad for Python

Installation:

pip install smarty-left-pad

Usage

    from smarty_left_pad.left_pad import left_pad

    >>>left_pad('input', 10, '-')
    -----input

This package uses doctest for testing, run :code:doctest left_pad.py to run the tests.

Example of run log:

(personal386) $ pwd
/smarty-left-pad/pad_on_left
(personal386) $ python -m doctest left_pad.py -v
Trying:
    left_pad('foo', 5)
Expecting:
    '  foo'
ok
Trying:
    left_pad('foobar', 6)
Expecting:
    'foobar'
ok
Trying:
    left_pad('toolong', 2)
Expecting:
    'toolong'
ok
Trying:
    left_pad(1, 2, '0')
Expecting:
    '01'
ok
Trying:
    left_pad(17, 5, 0)
Expecting:
    '00017'
ok
1 items had no tests:
    left_pad
1 items passed all tests:
   5 tests in left_pad.left_pad
5 tests in 2 items.
5 passed and 0 failed.
Test passed.
(personal386) $

In case of a failure:

Failed example:
    left_pad('foo', 5)
Expected:
    '  fooN'
Got:
    '  foo'

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

smarty-left-pad-1.0.4.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

smarty_left_pad-1.0.4-py2.py3-none-any.whl (7.3 kB view hashes)

Uploaded Python 2 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