On Thu, Sep 17, 2020, 2:36 AM Dennis Sweeney <[email protected]>
wrote:

>     >>> f"It is {hh}:{mm} {am_or_pm}" = "It is 11:45 PM"
>     >>> f"It is {hh}:{mm} {am_or_pm}" == "It is 11:45 PM"


I cringe at every part of this proposal. But this is especially perplexing.
How can it POSSIBLY work, unless we have "spooky action at a distance"?!

The proposal a terrible abuse of OUTPUT f-strings. It is confusing,
unclear, ambiguous, and would make code far harder to read.

Having some sort of library for template matching seems fine. Letting the
mini-language be inspired by f-strings seems fine. It should show it's
merit as a third party tool first, but I can imagine using such.

This I wouldn't hate:

hour, minute, daytime = template(
    pattern="It is {hh}:{mm} {am_or_pm}",
    instance="It is 11:45 PM")

There are lots of specifics to work out, like what to do if things don't
match up between pattern and instance.  I deliberately changed, e.g. 'hh'
in the pattern to 'hour' as the binding, because bindings are just names.

I suppose returning a dictionary using the names in the pattern might work
also. Whatever, those are details of a separate library, not a syntax
change.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/JWFSWF52GKP5BAWSAJCA4VPAJ6CZ6V4O/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to