Skip to content

Instantly share code, notes, and snippets.

@AaronPhalen
Last active September 24, 2015 03:56
Show Gist options
  • Save AaronPhalen/609d24c453e8b08f561a to your computer and use it in GitHub Desktop.
Save AaronPhalen/609d24c453e8b08f561a to your computer and use it in GitHub Desktop.
# Author: Aaron Phalen | Twitter: @aaron_phalen | Email: [email protected]
# Builder Design Pattern In Python
# Creating xml without builder as constract to example
from lxml import etree
root = etree.Element("root")
child = etree.Element("child")
child.text = "sample text"
root.append(child)
# Creating xml with builder to highlight elegance
from lxml.builder import E
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment