Format number through scripting

I get a formatted output of #000.0 from sepasoft method and want to format my number to match this format.
The formatted output differs from test to test which is why I make this call. Is there a way to force this format in scripting using this outputted format?

I'm trying to understand what you're saying, but formatting essentially is "converting" a floating point value over to a string using a specified format. Is this your intent? Typically you'd only want to do this at the client display/UI level and not for passing values out of a script.

If you are wanting to pass this out of a script, use something like the following for 1 decimal place:

return "%.1f" % value

If you want to force a minimum fixed set of characters, you can use this for a minimum of 5 characters (3 to the left of the decimal, the decimal itself, and 1 after the decimal):

return "%5.1f" % value

If you want them zero prefixed, you'd use this:

return "%05.1f" % value

Perhaps you can get Nick to share his code from this topic:

If I remember correctly, the Sepasoft SPC module, for example, stores values as a string in the database (since value could be many different things). When you return the result, it returns as a string type. You can confirm this by using type() and see it comes back as a string or float. Either way, you'll need to explicitly convert that string to a float, then apply the formatting you want so they all "look" the same.