Install & Compatibility
Where this runs
tested against v2.15.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.006s · 19.4MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.4s · import 0.006s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Parser
✓ from pypeg2 import Parser
correct import path
Symbol
✓ from pypeg2 import Symbol
correct import path
Keyword
✓ from pypeg2 import Keyword
correct import path
Namespace
✓ from pypeg2 import Namespace
correct import path
attr
✓ from pypeg2 import attr
correct import path
parse
✓ from pypeg2 import parse
correct import path
Define a simple grammar with classes and parse a string.
from pypeg2 import Symbol, Keyword, attr, parse
class Name(Symbol):
grammar = attr('first', str), attr('last', str)
class Greeting(Keyword):
grammar = 'hello'
class Sentence:
grammar = Greeting, Name
result = parse('hello John Doe', Sentence)
print(result.greeting, result.name.first, result.name.last)
Errors
Common errors & fixes
AttributeError: module 'pypeg2' has no attribute 'parse'
Incorrect import; installed `pypeg` instead of `pypeg2`.
fixInstall correct package: `pip install pypeg2` and use `from pypeg2 import parse`.
TypeError: 'Symbol' object does not support indexing
Treating a parsed `Symbol` as a tuple/list instead of accessing its attributes.
fixParse result is an object with attributes; use dot notation like `result.name.first`.
ImportError: cannot import name 'Parser' from 'pypeg2'
Typo in import; correct symbol is `Parser` but some older documentation shows `parser` (lowercase).
fixUse correct import: `from pypeg2 import Parser` (capital P).
Upgrade
Version history
2.15.2latest on PyPI · released Oct 7, 2015
Audit
Dependencies
No dependency data recorded yet.