Quickstart
This guide gets you building with Bag builders in 5 minutes.
Installation
pip install genro-bag
Your First Builder
Let’s create a simple menu structure:
Using HtmlBuilder
For HTML, use the built-in HtmlBuilder:
Attributes
Pass attributes as keyword arguments. Use class_ for the class attribute (since class is a Python reserved word):
Tip
Use saved references (like a and div above) to access attributes instead of
auto-generated paths like bag['a_0?href']. References are stable and don’t depend
on insertion order.
Branch vs Leaf Nodes
Understanding when you get a Bag vs a BagNode is key:
Next Steps
Learn to create custom builders
Explore HtmlBuilder features
Understand validation
Master advanced patterns