03 Dec 2012, 22:20
Generic-user-small

J.J. Bosman (3 posts)

When I copy a text from the epub Pract progr. like def to_celsius(t):​​ return (t - 32.0) * 5.0 / 9.0​​ ​​​​ def above_freezing(t):​​ return t > 0​​ into Wing IDE nothing does as I expect. wrong asci, to_celcius does not exist etc. what is wrong??

03 Dec 2012, 23:03
Generic-user-small

J.J. Bosman (3 posts)

import temperature temperature.above_freezing(temperature.to_celsius(33.3)) Traceback (most recent call last): File “", line 1, in AttributeError: 'module' object has no attribute 'to_celsius'

I do not know whaT this is.

05 Dec 2012, 18:23
Paul_mugshot_pragsmall

Paul Gries (44 posts)

Hi J.J.,

It looks like a font problem between epub and Wing. I copied and pasted your code and it had syntax errors for me. I also tried copying and pasting from the PDF version, and that one actually worked. Here’s what I have in temperature.py:

def to_celsius(t):
    return (t - 32.) * 5 / 9

def above_freezing(t):
    return t > 0

And here is my shell interaction:

>>> import temperature
>>> temperature.above_freezing(temperature.to_celsius(33.3))
True

My guess for what caused your problem is that, because there was a syntax error in your temperature.py file, the functions weren’t getting properly define.

  You must be logged in to comment