[Python-ideas] Dictionary initialization to capture syntax and value (was Re: Debugging: some problems and possible solutions)
Steven D'Aprano
steve at pearwood.info
Wed Oct 3 19:13:52 EDT 2018
On Thu, Oct 04, 2018 at 04:17:41AM +1000, Chris Angelico wrote:
> > {=(1 + bar), }
> > is equivalent to
> > {'1 + bar': 1 + bar, }
What is so special about dicts that this only works there?
If we're going to have syntax to capture the source (and AST) of an
expression, it ought to work everywhere. And it ought to be callable,
without having to call eval() on the source, which is slow.
--
Steve
More information about the Python-ideas
mailing list