Skip to main content
https://img.shields.io/pypi/v/cooked_input.svg https://img.shields.io/pypi/l/cooked_input.svg https://readthedocs.org/projects/cooked-input/badge/?version=latest https://github.com/lwanger/cooked_input/actions/workflows/tests.yml/badge.svg https://img.shields.io/pypi/pyversions/cooked_input.svg

Cooked Input Project

cooked_input is a Python package for getting, cleaning, converting, and validating input. If you think of input (raw_input in legacy Python) as raw input, then this is cooked input.

cooked_input provides a simple and safe way to get validated command line input that ranges from the simplest of Python programs to sophisticated database driven applications. Beginner’s can use the provided convenience classes to get simple inputs from the user. Following the quick start guide you can be up and running in minutes.

More advanced users can easily create custom classes for sophisticated cleaning and validation. Cooked_input can also be used to create menus and data tables. The latter tutorials (part one and part two) and examples show several examples ranging from simple to sophisticated calls.

Cooked_input also provides a pathway to use the same cleaning and validation logic used in the command line for validating web or GUI based inputs.

Documentation

The documentation is available at: http://cooked-input.readthedocs.io/en/latest/

Python Support

cooked_input requires Python 3.10 or later, and has been tested through Python 3.14. Python 2 is no longer supported (the last release supporting it is v0.5.4).

Release Notes

v0.7.0 is a large release by volume of change, even though it adds no new functionality. It is almost entirely work on the inside of the package. Every function, method and class was annotated with types, and a py.typed marker now ships so downstream projects actually see them; the test suite went from 86 tests at 79.6% coverage to 661 at 100%; and the two largest modules were split along the seam they already had. Reading essentially all of the code that way turned up thirty-two real defects that had been sitting behind an untyped signature or an untested line, and those fixes are the bulk of the release.

There are breaking changes. Most code will not notice, but they are worth a look before upgrading:

  • DecimalConvertor now honours precision and rounding, which it had been ignoring, so get_money(precision=2) returns different numbers than it used to.

  • Table.scroll_up_one_row and Table.scroll_down_one_row had their bodies the wrong way round and now move the view in the direction they are named for.

  • get_menu returns 'exit' where it used to hand back a TableItem, and Table.get_table_choice returns None when the exit row is chosen.

  • A blank line at a required=True prompt is reported through error_callback and counts against retries, instead of being skipped in silence – which had been an infinite loop.

  • in_all, in_any and not_in are no longer importable from cooked_input. They were always internal plumbing and appeared in no documentation. validate() is unaffected.

  • The module-level validation helpers, and SimpleValidator, now return a real bool rather than passing a validator’s truthy return value through, and return True rather than None when there is nothing to validate.

  • GetInput and every get_* function take their options as named keyword-only parameters instead of a **options dictionary. An unrecognised option raises a TypeError rather than logging a warning and carrying on with the default, so get_int(promt="Age?") is now reported instead of quietly asking the wrong question. Code that builds an options dictionary still works by unpacking it: get_int(**options).

  • Table, create_table, get_menu, Table.get_table_choice and get_table_input changed the same way. An unrecognised option raises a TypeError rather than being silently ignored – which is how two bugs in the shipped examples had gone unnoticed.

  • Cleaner, Convertor and Validator are now real abstract base classes. A subclass that never implemented __call__ raises TypeError when instantiated, where before it silently returned None from every call.

  • A single string given to AnyOfValidator or NoneOfValidator is now one choice rather than being iterated one character at a time.

See CHANGELOG.rst for the full list, including the defects the type checker found and what each of them affected.

Installation

pip install cooked_input

Project Page

Project information and source code is available at: https://github.com/lwanger/cooked_input

Tutorial

The best way to get started is to read the quick start at: http://cooked-input.readthedocs.io/en/latest/quick_start.html

After that, more advanced usage can be learned from the tutorial at: http://cooked-input.readthedocs.io/en/latest/tutorial.html

Download files

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

Source Distribution

cooked_input-0.7.0.tar.gz (152.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cooked_input-0.7.0-py3-none-any.whl (149.7 kB view details)

Uploaded Python 3

File details

Details for the file cooked_input-0.7.0.tar.gz.

File metadata

  • Download URL: cooked_input-0.7.0.tar.gz
  • Upload date:
  • Size: 152.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cooked_input-0.7.0.tar.gz
Algorithm Hash digest
SHA256 20132bf962aa466d7e1492fb9dd7eb3594b221be657e14275585d03db5efa26d
MD5 89bd426289e6b43bd421b96d420cfb26
BLAKE2b-256 c652799fb6169db013f15e200f6a22ca36fdb12a0011c7651e5212019cbe9ff7

See more details on using hashes here.

Provenance

The following attestation bundles were made for cooked_input-0.7.0.tar.gz:

Publisher: release.yml on lwanger/cooked_input

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cooked_input-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: cooked_input-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 149.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cooked_input-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2358339e2a9f2ec06cd4cf0a0c1bad30405646aa2bbb760fc60c61a86592abaa
MD5 421712bce2ffa8140902916239b0c5ca
BLAKE2b-256 73183e6391286c463f34b4696e4588ef1f4303844d1b74507aaaa23aca974491

See more details on using hashes here.

Provenance

The following attestation bundles were made for cooked_input-0.7.0-py3-none-any.whl:

Publisher: release.yml on lwanger/cooked_input

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page