> So now that I know better, I'm trying to write the beginnings of a > general setPrecision() function using format strings. However, it > appears that a variable cannot be used instead of the ".2" in > > "%.2f" % 2.234234
The trick is to create the format string using the variable then use the format string for your final result: value = 11234.23456789345 width = 12 precision = 3 fmt = "%%s.%sf" % (width,precision) result = fmt % value HTH, Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor