
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
| |version| |versions| |impls| |wheel| |coverage|
.. |version| image:: http://img.shields.io/pypi/v/say.svg?style=flat :alt: PyPI Package latest release :target: https://pypi.org/project/say
.. |versions| image:: https://img.shields.io/pypi/pyversions/say.svg :alt: Supported versions :target: https://pypi.org/project/say
.. |impls| image:: https://img.shields.io/pypi/implementation/say.svg :alt: Supported implementations :target: https://pypi.org/project/say
.. |wheel| image:: https://img.shields.io/pypi/wheel/say.svg :alt: Wheel packaging support :target: https://pypi.org/project/say
.. |coverage| image:: https://img.shields.io/badge/test_coverage-97%25-blue.svg :alt: Test line coverage :target: https://pypi.org/project/say
It's been almost fifty years since C
introduced printf()
and the basic
formatted printing of positional parameters. Isn't it time for an upgrade?
You betcha!
say
evolves Python's print
statement/function, format
function/method, and %
string
interpolation operator with simpler, higher-level facilities. For example,
it provides direct template formatting::
from say import *
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'
Or instead of printing the string immediately, you want the string itself,
the fmt()
function is our version of sprintf()
.::
>>> fmt("{name} has {x} things and {len(nums)} numbers.")
'Fred has 12 things and 4 numbers.'
The more items being printed, and the more complicated the format
invocation, the more valuable this simple inline specification becomes.
But as nice as replacing positional templates with inline
templates
is--a fact finally officially accommodated with
formatted string literals of Python 3.6--say
does a lot more.
It also works in a variety of ways to up-level the output-generation task.
For 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 proper title and indentation, and just the variable information in blue.
.. image:: http://content.screencast.com/users/jonathaneunice/folders/Jing/media/81bf4738-c875-4998-82ac-a91d211d000b/00000745.png :align: left
say
provides:
format()
method, syntax, and underlying engine.fmt()
object for string formatting.Take it for a test drive today! See the full documentation at Read the Docs <http://say.readthedocs.org/en/latest/>
_.
FAQs
print and format on steroids
We found that say demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.