[Tutor] Error when calling a class

kubota2550 at gmail.com kubota2550 at gmail.com
Sun Feb 18 15:38:18 CET 2007


I'm learning about creating classes and have created the simple class below:


class Temperature (object):

    def fahrenheit(self):
        return 32 + (1.8 * self.celsius)


d = Temperature()

d.celsius = float(input())
print d.fahrenheit()



This works fine stand-alone but I can't get it to work when I try to call it
from another program.  This program is called classctof and the call program
is:





import classctof

y=classctof.fahrenheit(1)

print y



What am I doing wrong to get it to pass the answer back to the calling
program?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070218/0fa8b04b/attachment.html 


More information about the Tutor mailing list