Python troubles (classes, SUPER BASIC)

So I was messing around with python classes and I had trouble understanding it, this is what I came up with

class Forest:
    def temperature (self,temperature):
        self.temperature=temperature
    def displayTemp (self):
        return self.temperature
    def saying(self):
        print "This soup is %s" % self.displayTemp  

first=Forest()
second=Forest()
third=Forest()

first.temperature('too cold.')
second.temperature('warm.')
third.temperature('too hot.')

temperature=input("1~10; How hot is the soup? ")
int(temperature)

if (temperature<=3):
    first.saying
elif (temperature==4,5,6):
    second.saying
else:
    third.saying

the goal was for it to ask a question like "1~10; How hot is the soup? " and then you put in a number (1-3 = too cold; 4-6 warm; 7-10 too hot) but instead of calling back the response it doesn't do anything.

I'm totally new to python and I have looked around but my lack of understanding makes it harder for me and I read a couple things here on what I thought it might be, but no luck.

Answers


Your code has several problems.

By itself first.saying is just a reference to the function object; you need parentheses to actually call it: first.saying(), second.saying(), etc. You need to do the same with self.displayTemp().

Also, int(temperature) doesn't change the value of temperature; it returns a new value that is converted to int. If you want to replace the old value, you need to do temperature = int(temperature).

Also temperature==4,5,6 won't do what you seem to want. You need to do something like 4 <= temperature <= 6.

You should read the Python tutorial to get familiar with the basics of Python.


Need Your Help

Hooking ReadFile WinAPI

c++ winapi visual-c++ hook

Im using mhook C++ lib to hook WinAPI. I have a problem..