Fixed bug with decimal value string formatting
authorLaurent Bessard
Mon, 11 Nov 2013 00:59:19 +0100
changeset 1374 1eefc427419f
parent 1373 4278d5c1e414
child 1375 dc94c71a2f25
Fixed bug with decimal value string formatting
xmlclass/xsdschema.py
--- a/xmlclass/xsdschema.py	Thu Nov 07 00:31:46 2013 +0100
+++ b/xmlclass/xsdschema.py	Mon Nov 11 00:59:19 2013 +0100
@@ -45,7 +45,8 @@
     return generateXMLTextMethod
 
 def GenerateFloatXMLText(extra_values=[], decimal=None):
-    float_format = ("{:.%dg}" % decimal).format if decimal is not None else str
+    float_format = (lambda x: "{:.{width}f}".format(x, width=decimal).rstrip('0')
+                    if decimal is not None else str)
     def generateXMLTextMethod(value, name=None, indent=0):
         text = ""
         if name is not None: