[Python-ideas] Dart-like method cascading operator in Python
Stephen J. Turnbull
stephen at xemacs.org
Sat Nov 23 12:17:34 CET 2013
Perešíni Peter writes:
> Anything which is tree-like (e.g. mentioned DSLs, API wrappers
> around complicated objects (e.g. xml), configurations, gnuplot
> example, ...) can be difficult to instantiate using normal syntax:
> tree = Tree()
> ..newChild(value=5)
> ..newChild(value=3)
> ..newChild()
> ..newChild(color="green")
This particular application just screams for positional parameters,
though:
tree = Tree(
Node(
Node(value=3),
Node(),
value=5),
Node(color="green"))
(YMMV about positioning of the parens, to me this is the one that says
"TREE!! and here are the Nodes" most clearly.)
More information about the Python-ideas
mailing list