On Thu, Oct 22, 2020 at 4:17 AM Guido van Rossum <gu...@python.org> wrote:
> In terms of API, assuming functions, I think there are two basic models. > We could have two (or more) functions that were related though: >> >> # E.g. pat_with_names = "{foo:f}/{bar:4s}/{baz:3d}" >> matches = scan_to_obj(pat_with_names, haystack) >> # something like (different match objects are possible choices, dict, >> dataclass, etc) >> print(matches.foo) >> print(maches['bar']) >> # pat_only = "{:f}/{:4s}/{:3d}" >> foo, bar, baz = scan_to_tuple(pat_only, haystack) >> # names, if bound, have the types indicated by scanning language >> > > Hmm, if the above is acceptable, maybe f-strings are still the logical > next step, since they bring the format and the target name together again. > Sure, but they need to be "f-like-strings". Some things are not allowed, e.g. no "{foo+1}". And there shouldn't be an 'f' prefix since they are NOT interpolated where written. But most of the format language can work. -- The dead increasingly dominate and strangle both the living and the not-yet born. Vampiric capital and undead corporate persons abuse the lives and control the thoughts of homo faber. Ideas, once born, become abortifacients against new conceptions.
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/VQRUTRMYVLYOCA5QCI4DYSC5M6GWBW4P/ Code of Conduct: http://python.org/psf/codeofconduct/