What is pyparsing?
Small text formats get parsed with fragile regular expressions that nobody can read later.
Small text formats get parsed with fragile regular expressions that nobody can read later.
Apart from marked quotes, everything on this page comes from our own test run.
How we tested pyparsing
We ran pyparsing 3.3.3 on (UTC) in an isolated sandbox: Ubuntu 26.04 under WSL2 with Python 3.14. Networking was switched off, so nothing was downloaded or sent during the test. The test ran as an unprivileged user with an empty home directory.
Sandbox checks recorded before the run, all passed: network disabled, home directory blocked, secrets blocked, writes limited to the test workspace.
Setup as recorded: WSL2 Ubuntu 26.04 sandbox: no network, read-only root, nobody user; Python 3.14; local copy of the installed release.
- The input file
example.py(153 bytes) was placed in an empty workspace. - We ran
bin/test example.py. It exited with code 0. - We kept the exact output (132 bytes) and compared it with the input byte for byte.
- The terminal session was recorded (6.63 seconds).
bin/test is defined by the test definition in our repository (config/curation/pyparsing-3.3.3.json), shown below as it stood when this page was built. The script itself is not part of the hashed test record, unlike the input, output and command above.
#!/usr/bin/python3 -I
import contextlib
import io
import sys
import time
START = time.perf_counter()
sys.path.insert(0, "/tmp/ws")
OUT = []
def check(label, test):
try:
ok = bool(test())
except BaseException as exc:
ok = False
print("check %r raised %s" % (label, type(exc).__name__), file=sys.stderr)
OUT.append((ok, label))
NS = {"__name__": "readme_example"}
PRINTED = io.StringIO()
try:
with contextlib.redirect_stdout(PRINTED):
exec(compile(open(sys.argv[1], encoding="utf-8").read(), sys.argv[1], "exec"), NS)
RAN = True
except BaseException as exc:
RAN = False
print("README example failed: " + type(exc).__name__, file=sys.stderr)
import pyparsing as pp
G = NS.get("greet")
check("pyparsing example", lambda: RAN and PRINTED.getvalue() == "Hello, World! -> ['Hello', ',', 'World', '!']\n")
check("Extra spaces ok", lambda: G.parse_string("Hello , World !").as_list() == ["Hello", ",", "World", "!"])
check("Missing space ok", lambda: G.parse_string("Hello,World!").as_list() == ["Hello", ",", "World", "!"])
NAMED = pp.Word(pp.alphas)("salutation") + "," + pp.Word(pp.alphas)("addressee") + "!"
check("Named results", lambda: NAMED.parse_string("Hi, Ada!").addressee == "Ada")
def refused():
try:
G.parse_string("Hello World")
except pp.ParseException:
return True
return False
check("Bad greeting refused", refused)
for ok, label in OUT:
print(("PASS " if ok else "FAIL ") + label)
print("%d/%d passed in %.2f s" % (sum(o for o, _ in OUT), len(OUT), time.perf_counter() - START))
What we saw
What we tried: Run the README's greeting grammar and compare its printed output, whitespace handling, named results and a refused input.
What went in: 4 lines of text (153 bytes).
What came out: 6 lines of text (132 bytes).
Exact recorded input and output. Invisible characters are written out (for example \x1b is the escape character) so you can see them.
from pyparsing import Word, alphas
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
print(hello, "->", greet.parse_string(hello))
PASS pyparsing example
PASS Extra spaces ok
PASS Missing space ok
PASS Named results
PASS Bad greeting refused
5/5 passed in 0.09 s
Measured result
- Input size
- 153 bytes
- Output size
- 132 bytes
- Sandbox run time
- 11.44 seconds: the whole isolated sandbox run, including sandbox start-up. This is not the tool's own processing time.
- Demo recording length
- 6.63 seconds
Recorded measurement: 5 of 5 README checks passed in 0.09 seconds.
Limits of this test
The parsed results returned from ``parse_string()`` is a collection of type ``ParseResults``, which can be accessed as a nested list, a dictionary, or an object with named attributes.
This record covers one input, one version (3.3.3) and one platform (Ubuntu 26.04 under WSL2). It is not a speed benchmark: the sandbox time includes start-up. We did not run it on Windows or macOS here, so results there may differ.
Is pyparsing a fit for you?
- Check further if your input goes beyond our sample: the limit quoted above comes from the project itself.
- Check further if you need it on Windows: this record covers Ubuntu 26.04 under WSL2 only.
Questions this test answers
Did we test pyparsing on Windows?
No. This record ran on Ubuntu 26.04 under WSL2. It does not show how pyparsing behaves in a Windows console.
Which version did we test, and when?
pyparsing 3.3.3, on (UTC).
Did the test need internet access?
No. The sandbox had networking switched off for the whole run.
What does pyparsing not handle?
Our single input does not probe this. The project names its own limit, quoted under Limits of this test; inputs like that need their own test.
Watch the test
Pressing play loads the YouTube player from youtube-nocookie.com; YouTube (Google) then applies its own privacy policy. Nothing is loaded from YouTube before you press play. Privacy
Transcript
Parse text with readable Python, not regex.
It's a Python library for building parsers directly in Python code, as an alternative to regular expressions. It has 2,497 stars on GitHub and an MIT license.
Here is what it gives you: one, grammar in python; two, readable results; three, clear failures.
We ran the README example in a sandbox with no network: 5 checks in all.
Result: 5 of 5 checks passed in 0.09 seconds.
Our verdict: it works. One honest limit: we only parsed short greetings here, not a full language.
Full test results are in the Tools link on our profile.
Test records
Each test keeps the code shown in its video. Code PYPRSR leads here; you can also search any code on Find a code.
| Code | Tested | Version | Platform | Result |
|---|---|---|---|---|
| PYPRSR | 3.3.3 | Ubuntu 26.04 under WSL2 | see record |
Official links
- Source repository ↗
- README at version 3.3.3 ↗ · captured
Related tools we tested
- cachetools: see record
- filelock: see record
- fsspec: see record
- httpx: see record
- more-itertools: see record
- multidict: see record
License and attribution
- MIT — pyparsing by Paul McGuire (MIT)
Rights holder: Paul McGuire. Permission: use_modify_distribute License source ↗ - LicenseRef-RepoProof-Owned — RepoProof
Rights holder: RepoProof. Permission: use_modify_distribute License source ↗
Covers 6 assets: demo input, demo output, demo recording, input frame, output frame, demo extra checks json. - LicenseRef-RepoProof-Owned — RepoProof capture of github.com/pyparsing/pyparsing
Rights holder: RepoProof. Permission: use_modify_distribute License source ↗
Covers 3 assets: demo extra github page png, demo extra github stars png, demo extra github json.
Production note
AI-assisted script and synthetic narration; demo recorded by our automated test workflow.
Page text is assembled from the recorded test data. Sentences taken from the tool's README are marked as quotes.