A new release for outputformat is available! Now at v0.1.3 we get some cool features:

  • Show dictionaries using ouf.showdict
  • Bold text using ouf.b
  • Color text with ouf.c
  • Break several lines using ouf.br
  • New ‘big’ style for ouf.bigtitle
  • Basic colormaps implemented, list at ouf.color.cmaps
  • Rainbow text that follows a cmap using ouf.rainbow

Upgrade to the latest version using pip

pip install outputformat --upgrade

All the examples here will use ouf as alias for outputformat

import outputformat as ouf

Show dict

Using the same style standards as for ouf.showlist, now ouf.showdict is available:

The dictionary may contain mixed types of data, they will processed for the cleanest presentation possible. The parameter precision defines how many decimals to show in case of floats.

Text formating

Two simple but useful new features are ouf.b("text to be bold") that will simply print the text in bold, and ouf.br(4)that will break the number of given lines.

We can also add color to text, using ouf.c:

The first parameter is the text do be printed, the second is the color to be used. Colors can be defined in different ways:

  • Hex code, for example #30AAFF
  • One float value. In this case a colomap, cmap will be used. The standard is a HSV colormap, but few other options are available.
  • A tuple of 3 values that will be interpeted as HSV. In my opinion Hue, Saturation and Value are way more intuitive than RGB values, so it’s easier to create the color you want.

Also, it’s always possible to make the text bold, by passing bold=True

A few colormap options were implemented so far, and are availabe at ouf.color.cmaps:

Which brings us to the most aesthetic new feature: ouf.rainbow. It will apply sequentially the colors of a colormap to any given string. For the extra punch, use bold=True:

All the other previous functionalities were also upgraded to receive the color parameter. This means we can use color="rainbow" for ouf.boxtitle, with some interesting results:

New style for bigtitle

A new style, big, was included for ouf.bigtitle. So now we have two styles available: small and big:

And, of course, color is now also an option for bigtitle:

For a description of the other functionatilies (up to v0.1.2) check this post. Development is happening periodically at GitHub, check it out if you’re looking to contribute!