Skip to content
This repository has been archived by the owner on Aug 26, 2018. It is now read-only.
/ formatizer Public archive

Literal string formatting for Python versions older than 3.6.

License

Notifications You must be signed in to change notification settings

fgimian/formatizer

Repository files navigation

Formatizer

Build Status Coverage Status License

Formatizer Logo

Artwork courtesy of Open Clip Art Library

Introduction

Formatizer provides literal string formatting for Python versions older than 3.6. This replaces the need for substitution using % or the format function.

Formatizer is covered by unit tests and Flake8 compliance. Please note that this library does use eval to perform its expression processing.

Quick Start

Install Formatizer in your virtualenv as follows:

pip install formatizer

And now, go ahead and use the f function similarly to PEP 498:

from __future__ import print_function
from formatizer import f

GREETING = 'hi'

def main():
    name = 'Fotis'
    print(f('My name is {name}, I say {GREETING} and 1 + 2 is {1 + 2}'))

if __name__ == '__main__':
    main()

All local and global variables will be recognised by the f function and complete Python expressions are also allowed between the braces much like Python 3.6.

Running Tests

You may run the unit tests as follows:

git clone https://github.com/fgimian/formatizer.git
cd formatizer
python setup.py test

License

Formatizer is released under the MIT license. Please see the LICENSE file for more details.

About

Literal string formatting for Python versions older than 3.6.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages