Paul Moore <p.f.mo...@gmail.com> added the comment:
+1 from me. It's something I'd find useful, and it's a natural extension of the f-string syntax. > I can't decide if I'm going to allow a format specifier. The only useful interpretation IMO would be for {expr!d:fmt} to expand to expr={expr:fmt}. If you're not willing to include that in the initial implementation, I'd rather see :fmt reserved for now, with the intention that it's implemented like this at a later date. Having :fmt apply to the whole string including the "expr=" bit would be basically useless to me. For a motivating example, consider f"{datetime.now()!d:%Y-%m-%d}", which is something I could easily imagine using. Steven D'Aprano: > I think there are enough use-cases for having access to > expressions, complete with source code, as first-class > values to make this a general feature of the language > and not baked into f-strings. I have a proto-PEP > discussing this. I have no problem with something like this, but I don't think it precludes the proposed f-string extension. The use cases are sufficiently different that I'd expect the two features to live happily together - there's no need to block the f-string extension for a proposal like this. ---------- nosy: +paul.moore _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36774> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com