Skip to main content
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!

replacement for string.Formatter supporting empy keys (recursively)

Project Description

This package is a backport of string.Formatter and its tests to Python 2.7 and 3.3 (and 3.4.0 as shipping with Ubuntu 14.04 LTS/Linux Mint 17)

It allows empty keys in format strings as introduced in Python 3.4.1, and fixes a bug ( "{:<{}} {}" ) when using nested empty keys, that is available in all versions of string.Formatter() allowing empty keys (up to at least 3.5.0rc3).

Usage

The package can be used as a replacement for string:

import string_formatter as string

TrailingFormatter

Additionally this package includes TrailingFormatter allow a type specification t with a single character parameter, that will be added to the (stringified) value before applying (left-aligned) formatting:

import string_formatter as string

fmt = string.TrailingFormatter()
d = dict(a=1, bc=2, xyz=18)
for key in sorted(d):
    print(fmt.format("{:t{}<{}} {:>3}", key, ':', 15, d[key]))

giving:

a:                1
bc:               2
xyz:             18
Release History

Release History

This version
History Node

1.0.1

History Node

1.0.0

History Node

0.1

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
string_formatter-1.0.1-py2.py3-none-any.whl (6.1 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Sep 9, 2015
string_formatter-1.0.1.tar.gz (8.4 kB) Copy SHA256 Checksum SHA256 Source Sep 9, 2015

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