formatist

Converts %-style format strings to newer {}-style


Keywords
string, format, pep3101, percent, braces
License
MIT
Install
pip install formatist==0.0.2

Documentation

formatist

https://travis-ci.org/moreati/formatist.svg?branch=master

A Python library to convert from older % style format strings, to newer {} style.

>>> import formatist
>>> greeting = "Hello %(name)s. It's %(temp).1f C"
>>> print(greeting % {'name': 'Alice', 'temp': 23.45678})
Hello Alice. It's 23.5 C
>>> greeting2 = formatist.convert(greeting)
>>> print(greeting2)
Hello {name!s:}. It's {temp:>.1f} C
>>> print(greeting2.format(name='Alice', temp=23.45678))
Hello Alice. It's 23.5 C