[Tutor] What does "TypeError: 'int' object is not iterable" mean?
Sander Sweers
sander.sweers at gmail.com
Thu Oct 21 23:21:13 CEST 2010
On 21 October 2010 18:09, Richard D. Moores <rdmoores at gmail.com> wrote:
> In case anyone's interested, the script now works the way I wanted:
> <http://tutoree7.pastebin.com/f9nDehNc>. It should work for anyone
> with 2.6 or 2.7
>
> I'd appreciate constructive criticism.
Instead of all the zeros2float craziness use string formatting. It
will take care of rounding and the number of decimal places.
>>> import datetime
>>> lowz = 81.7499997345
>>> timestamp = datetime.datetime.now().strftime("%H:%M:%S")
>>> print "NEW LOW: %.4f at %s" % (lowz, timestamp)
NEW LOW: 81.7500 at 22:55:13
If you want to control the number of decimal places in the string
formatting do something like:
>>> i = 3
>>> print ("NEW LOW: %%.%sf at %%s" % i) % (lowz, timestamp)
NEW LOW: 81.750 at 22:55:13
>>> i = 6
>>> print ("NEW LOW: %%.%sf at %%s" % i) % (lowz, timestamp)
NEW LOW: 81.750000 at 22:55:13
Greets
Sander
More information about the Tutor
mailing list