Format Input
Format Input is a small Python library for parsing console or text-stream input
according to a compact format specification. Instead of repeatedly calling
input(), splitting strings, and converting values by hand, describe the shape
of each input line once and receive typed Python values.
It is useful for:
- Competitive programming problems with predictable, line-based input.
- Command-line tools that read structured text.
- Small scripts that need to convert input into integers, floats, and strings.
- Situations where input may contain a mixture of scalar values, lists, and
values followed by free-form text.
For example, instead of manually splitting and converting a line:
parts = input().split()
count = int(parts[0])
ratio = float(parts[1])
name = parts[2]
You can describe the input once and receive typed values directly:
count, ratio, name = format_input("int float str")
See USAGE.MD for all supported types and format specifications.
Requirements
- Python 3.10 or newer
- No third-party dependencies
Installation
Clone the repository:
git clone https://github.com/GabbaTK/Format-Input.git
cd Format-Input
The package is stored in src/. To run the test suite from the repository root:
PYTHONPATH=src python -m unittest discover -s tests -v
License
This project is available under the MIT License.
AI disclosure
No AI was used in the making of the code.