Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 622 Bytes

README.rst

File metadata and controls

20 lines (16 loc) · 622 Bytes

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