On Sat, Nov 13, 2021 at 5:04 PM <[email protected]> wrote: > > > def hello(): > > try: > > hello_ = "Hello" > > world_ = "World" > > print(f"{hello_}, {world_}!") > > except TypeError as exc: > > print("failed: {}".format(exc)) > > > > if __name__ == "__main__": > > hello() > > > > > > # snippet from unittest/util.py > > _PLACEHOLDER_LEN = 12 > > def _shorten(s, prefixlen, suffixlen): > > skip = len(s) - prefixlen - suffixlen > > if skip > _PLACEHOLDER_LEN: > > s = '%s[%d chars]%s' % (s[:prefixlen], skip, s[len( > s) - suffixlen:]) > > return s >
0_o color me impressed, I did not think that would be legal syntax. Would be interesting to include in a textbook, if for nothing else other than to academically demonstrate that it is possible, as I suspect many are not aware. -- --Kyle R. Stanley, Python Core Developer (what is a core dev? <https://devguide.python.org/coredev/>) *Pronouns: they/them **(why is my pronoun here?* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/> )
_______________________________________________ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/4ZA2KK46JHENKSPB52RMXBAQT7CP3Q6A/ Code of Conduct: http://python.org/psf/codeofconduct/