On Thursday, September 5, 2019 at 9:28:17 AM UTC+1, Edward K. Ream wrote: > > > On Wed, Sep 4, 2019 at 9:54 AM rengel <reinhar...@gmail.com <javascript:>> >> wrote: >> >> Why not go for f-strings (Python 3.6+)...Less typing, Smaller, faster, >>> cleaner. >>> >> > *Supposed disadvantages of % * > > The python 3 docs > <https://docs.python.org/3/library/stdtypes.html#printf-style-bytes-formatting> > > say this about printf style (%) formatting: > > "The formatting operations described here exhibit a variety of quirks that > lead to a number of common errors (such as failing to display tuples and > dictionaries correctly). If the value being printed may be a tuple or > dictionary, wrap it in a tuple." > > I have never run across these difficulties. Note that pylint checks that > the number of % specs matches the number of args. > > *Real advantages of f-strings* > > - They do more clearly group arguments with specifiers. > > - no more typing %. > > - f-strings can be concatenated as usual, so line length doesn't matter > much. Your example could be given as: > > return ( > f'GS: {g.shortFileName(self.path):20} ' > f'{self.kind:7} = {val}' > ) > > Notice space at the end of the first f-string. > > *Summary* > > f-strings do have advantages, and there are tools > <https://pypi.org/project/fstringify/>to reformat % strings to f-string. > > However, I don't see any urgent reason to back port Leo's existing code. > > Edward >
IIUC, f-string formatting is *significantly* slower than old-style percentage usage. It might not be terribly important for Leo; personally I too have not rushed to change in my own code... -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/7d6b76b4-3379-41fe-9b6b-4e8c263657b6%40googlegroups.com.