[Tutor] FWD: How do I fix this error so that my exchange rates program will work?

Simon Gerber nequeo at gmail.com
Thu Dec 15 01:24:58 CET 2005


Sorry - Forgot to reply to the list as well.

---------- Forwarded message ----------

Hi Nathan,

Let's take a look at the debugger message:

> Traceback (most recent call last):
>   File "D:\Python24\exchange.py", line 84, in -toplevel-
>     save_rates(rates)
>   File "D:\Python24\exchange.py", line 9, in save_rates
>     store.write(rate + '\n')
> TypeError: unsupported operand type(s) for +: 'float' and 'str'

Well, looks like you're trying to add a number to a string. Sorry
mate, can't be done! Luckily, there's an easy fix. Change the number
into a string, just for the purpose of writing to the file. Python has
a very quick way of doing this.

Replace this:

>         store.write(rate + '\n')

With this:

           store.write(`rate` + \n')

Note that these are not your regular sungle quotes. You'll find them
above the tab key, under escape, on most standard keyboards.

Good luck!

--
Seen in the release notes for ACPI-support 0.34:

'The "I do not wish to discuss it" release
  * Add workaround for prodding fans back into life on resume
  * Add sick evil code for doing sick evil things to sick evil
    screensavers'


--
Seen in the release notes for ACPI-support 0.34:

'The "I do not wish to discuss it" release
  * Add workaround for prodding fans back into life on resume
  * Add sick evil code for doing sick evil things to sick evil
    screensavers'


More information about the Tutor mailing list