nvda icon indicating copy to clipboard operation
nvda copied to clipboard

Developer guide: start advertising f strings

Open LeonarddeR opened this issue 6 years ago • 7 comments

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}")

LeonarddeR avatar Oct 07 '19 13:10 LeonarddeR

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.

josephsl avatar Oct 07 '19 13:10 josephsl

Yes, that's a good point!

LeonarddeR avatar Oct 07 '19 14:10 LeonarddeR

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

Brian1Gaff avatar Oct 07 '19 15:10 Brian1Gaff

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.

josephsl avatar Oct 14 '19 03:10 josephsl

I think we should wait for Python 3.8 which supports the {variable=} cyntax, resulting into "name=value"

LeonarddeR avatar Oct 17 '19 13:10 LeonarddeR

There's a question.

Does benchmark matter for NVDA? If yes, the f-string is not very good.

ghost avatar Oct 21 '19 23:10 ghost

Now we are on Python 3.11. What is the current status on this? cc: @seanbudd

Adriani90 avatar Jun 28 '24 22:06 Adriani90

@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?

CyrilleB79 avatar Jul 01 '24 07:07 CyrilleB79

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 avatar Jul 02 '24 14:07 Nael-Sayegh

@Nael-Sayegh, just search for "%" in the developer's guide.

CyrilleB79 avatar Jul 02 '24 15:07 CyrilleB79