Developer guide: start advertising f strings
Is your feature request related to a problem? Please describe.
In the developer guide, we're using old style string formatting:
focusObj = api.getFocusObject()
name = focusObj.name
windowClassName = focusObj.windowClassName
ui.message("class for %s window: %s" % (name, windowClassName))
Describe the solution you'd like
This can be written as
focusObj = api.getFocusObject()
name = focusObj.name
windowClassName = focusObj.windowClassName
ui.message(f"class for {name} window: {windowClassName}")
Hi, I would say yes – note that we do need to think about transitioning some translatable (or most) strings to formatted string literals as it makes more sense for translators (at least if they are told what they are). Thanks.
Yes, that's a good point!
Is it just me who finds the old syntax easier to understand? Brian
[email protected] Sent via blueyonder. Please address personal E-mail to:- [email protected], putting 'Brian Gaff' in the display name field. Newsgroup monitored: alt.comp.blind-users
Hi,
To whoever is planning to research formatted string literals for messages, I think the best time to do it is early next year (with a separate issue of course). I'm willing to mentor a new developer over this project.
Thanks.
I think we should wait for Python 3.8 which supports the {variable=} cyntax, resulting into "name=value"
There's a question.
Does benchmark matter for NVDA? If yes, the f-string is not very good.
Now we are on Python 3.11. What is the current status on this? cc: @seanbudd
@Adriani90, the issue is triaged and p4. That means that NV Access is not likely to work on this, but any volunteer contribution is welcome.
@Nael-Sayegh maybe you want to work on this?
Hello, @CyrilleB79 Yes, I could work on the issue. @Adriani90 but I don't understand which part of NVDA is concerned, I couldn't find it in the developer's guide.
@Nael-Sayegh, just search for "%" in the developer's guide.