I've been having problems integrating the code used to extract temp/humidity measurements from the DHT22 into a larger python script. The following code works without issue -
import Adafruit_DHT as dht h,t = dht.read_retry(dht.DHT22, 4) print h print t
When the above script is run the shell prints the temperature and humidity readings as expected. However, if I try to incorporate line 2 (dht.read_retry) into an if statement or a while loop I either encounter an error or the shell becomes unresponsive. For example, if I run the following script nothing happens:
import Adafruit_DHT as dht var = 1 list1 =  if var == 1: h,t = dht.read_retry(dht.DHT22, 4) list1.append(h) list1.append(t) print list1
I would expect the shell to print the list but nothing happens. And in other, more elaborate, scripts I get errors relating to the line containing dht.read_retry.
Does anyone know why this occurs? I have some experience with python but this is my first Raspberry Pi project. Could it be because I'm using the python shell or am I using the Adafruit_DHT module incorrectly? Any help is appreciated.