On 24/11/20 9:44 am, David Mertz wrote:
m = Matcher(arbitrary_expression)
if m.case("StringNode(s)"):
     process_string(m.val)
elif m.case("[a, 5, 6, b]"):
     process_two_free_vars(*m.values)
elif m.case("PairNone(a, b)"):
     a, b = m.values
     process_pair(a, b)
elif m.case("DictNode"):
    foo = {key, process_node(child_node) for key, child_node in m.values.items()}

How does the Matcher object know the meanings of "StringNode",
"PairNode", etc.? Presumably they're bound to classes in the
namespace of the caller, but the Matcher doesn't know anything
about that namespace.

--
Greg
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/DVEMPPHHVZORWBNWVWJOJZHJMKYYEJ2H/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to