Arie Bovenberg <a.c.bovenb...@gmail.com> added the comment:
Indeed the `__format__` style offers a lot more options (see https://pyformat.info/). Regarding performance you make an interesting point. One possible solution is to allow f-strings _only_ if there are no args/kwargs. In that one case formatting would explicitly be skipped. This could be represented at type-level with an overload: # case: Logger does formatting. Only literal string template allowed. @overload def debugf(msg: Literal[str], *args, exc_info: bool = False, **kwargs): # wrap # case: User does formatting. No args/kwargs allowed. @overload def debugf(msg: str, *, exc_info: bool = False): # wrap `msg` in something that will not allow further formatting. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46200> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com