MichaelCook / textform

Python module to format values with a template string like Perl format.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

textform

Python module to format values with a template string like Perl format (perlform(1)).

In the template:

  • @<<<< Left justified field.
  • @>>>> Right justified field.
  • @|||| Centered field.

Any other text in the template is copied through to the result.

The "~~" feature of Perl format is implied: repeat until all fields are exhausted.

Example:

textform.format("@<<<<<<<<:@|||||||:@>>>>>>>",
                ["now is the time for all",
                 "good men to",
                 "come to the aid of their party"])

returns:

"now is   : good men :   come to\n" +
"the time :    to    :the aid of\n" +
"for all  :          :     their\n" +
"         :          :     party"

About

Python module to format values with a template string like Perl format.

License:BSD 2-Clause "Simplified" License


Languages

Language:Python 100.0%