/textform

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

Primary LanguagePythonBSD 2-Clause "Simplified" LicenseBSD-2-Clause

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"