> On Wed, Sep 4, 2019 at 9:54 AM rengel <[email protected]> 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

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/4cc6d637-d9da-4ae9-95f3-c6e392867b27%40googlegroups.com.

Reply via email to