How to display a value with its format


Is there a function or method that formats a value into a string according to the format?

I get the value of an attribute in the following way.
>>> attr_proxy = tango.AttributeProxy("meteo/alarm/shm/WindSpeed")

The display format of the value is given as follows.
>>> attr_proxy.get_config().format

I didn't find in the documentation (PyTango API) a function that formats a string according to this format (to obtain "2.70" in this case). Of course I can code it, but I would like to use a Python API function.

Thank you for reading my request!
Edited 1 month ago

I don't see anything like that in PyTango. Where do you think we should add it? A method on AttributeProxy? A general utility function? Please propose some options with the function/method signature, and expected behaviour.

Taurus has that kind of thing built in for GUIs, but it would be nice to have in PyTango as well.

Hi Anton,

Thank you for your prompt response. I will code a solution and propose it in the GitLab project (pytango) if possible (?). Can I propose such a GitLab ticket in order to have a discussion and a follow-up?

I don't see yet if this would be a feature in AttributeProxy or a general utility function.

It is also about capturing the wrong formatting according to the type of data…

Best regards,
Yes, please create an issue in the GitLab project with your proposal(s).

You may find some clues in the Taurus code. E.g.,

Hi Anton,

I created the ticket Issue #480 (Format a value with the format string spectification).

In the meantime, for my own needs I have developed a very simple function that only takes the float format into account.

Edited 1 month ago
Hi Jean-Christophe

Thanks, I saw your nicely detailed proposal. The PyTango developers are focused on the 9.4.0 release at the moment, but once that is done we can look into this proposal.

Register or login to create to post a reply.