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 supplements or replaces Python’s print statement/function, format function/method, and % string interpolation operator with higher-level facilities:

  • Straightforward string formatting with DRY, Pythonic templates that piggyback the built in format() method, formatting syntax, and well-proven underlying engine.
  • A single output mechanism compatible with both Python 2.x and Python 3.x–dramatically more compatible than Python’s own print.
  • Indentation and wrapping (to help stucture output)
  • Convenience printing functions for horizontal rules (lines), titles, and vertical whitespace.
  • Convenient template/text aggregator objects for easily building, reading, and writing multi-line texts.

Usage

from say import say, fmt

x = 12
nums = list(range(4))

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

yields:

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

say is basically a simpler, nicer recasting of:

print "There are {} things.".format(x)
print "Nums has {} items: {}".format(len(nums), nums)

(NB in Python 2.6 one must number each of the {} placeholders–e.g. "Nums has {0} items: {1}"– in order to avoid a ValueError: zero length field name in format error. Python 2.7 and later assume the placeholders are sequential.)

The more items that are being printed, and the complicated the format invocation, the more valuable having it stated in-line becomes. Note that full expressions are are supported. They are evaluated in the context of the caller.

For this and much more, see the full documentation at Read the Docs.

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

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

This version
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.0.2.tar.gz (15.4 kB) Copy SHA256 hash SHA256 Source None Sep 14, 2013
say-1.0.2.zip (20.8 kB) Copy SHA256 hash SHA256 Source None Sep 14, 2013

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