Skip to main content

Super-simple templated printing. E.g.: say("Hello, {whoever}!", indent=1)

Project description

print, format, and %, evolved.

Q: It’s been forty years since C introduced printf() and the basic formatted printing of positional parameters. Isn’t it time for an upgrade?

A: Yes! ZOMG, yes!

https://pypip.in/d/say/badge.png

say goes beyond Python’s print statement/function, format function/method, and % string interpolation operator with simpler, higher-level facilities. For example:

from say import say

x, nums, name = 12, list(range(4)), 'Fred'

say("There are {x} things.")
say("Nums has {len(nums)} items: {nums}")
say("Name: {name!r}")

yields:

There are 12 things.
Nums has 4 items: [0, 1, 2, 3]
Name: 'Fred'

At this level, say is basically a simpler, nicer recasting of:

from __future__ import print_function

print("There are {0} things.".format(x))
print("Nums has {0} items: {1}".format(len(nums), nums))
print("Name: {0!r}".format(name))

The more items being printed, and the more complicated the format invocation, the more valuable this simple inline specification becomes.

One final example:

say.title('Discovered')
say("Name: {name:style=blue}", indent='+1')
say("Age:  {age:style=blue}", indent='+1')

Prints a nicely formatted text block, with a propert title and indentation, and just the variable information in blue.

Beyond DRY, Pythonic templates that piggyback the Python’s well-proven format() method, syntax, and underlying engine, say’s virtues include:

  • A single output mechanism that works the same in either Python 2 or Python 3.
  • A companion fmt() object for string formatting.
  • Higher-order line formatting such as line numbering, indentation, and wrapping built in.
  • Convenient methods for common formatting items such as titles, horizontal separators, and vertical whitespace.
  • Easy styled output, including ANSI colors and user-defined styles and text transforms.
  • Easy output to one or more files, with no additional code.
  • Super-duper template/text aggregator objects for easily building, reading, and writing multi-line texts.

Take it for a test drive today! See also the full documentation at Read the Docs.

https://assets-gittipllc.netdna-ssl.com/13.1.2/logo.png

Project details


Release history Release notifications

History Node

1.6.5

History Node

1.6.4

History Node

1.6.3

History Node

1.6.2

History Node

1.6.1

History Node

1.6.0

History Node

1.5.1

History Node

1.5.0

History Node

1.4.5

History Node

1.4.4

History Node

1.4.3

History Node

1.4.2

History Node

1.4.1

History Node

1.4.0

History Node

1.3.12

History Node

1.3.10

History Node

1.3.9

History Node

1.3.8

History Node

1.3.7

History Node

1.3.6

History Node

1.3.5

History Node

1.3.4

History Node

1.3.3

History Node

1.3.2

History Node

1.3.1

History Node

1.3.0

History Node

1.2.7

History Node

1.2.6

History Node

1.2.5

This version
History Node

1.2.4

History Node

1.2.3

History Node

1.2.1

History Node

1.2.0

History Node

1.1.0

History Node

1.0.5

History Node

1.0.4

History Node

1.0.3

History Node

1.0.2

History Node

1.0.1

History Node

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
say-1.2.4.tar.gz (23.7 kB) Copy SHA256 hash SHA256 Source None Jun 4, 2014
say-1.2.4.zip (31.2 kB) Copy SHA256 hash SHA256 Source None Jun 4, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page