#!/usr/bin/python

import sys
import Adafruit_DHT

# Parse command line parameters.
sensor_args = { '11': Adafruit_DHT.DHT11,
		'22': Adafruit_DHT.DHT22,
		'2302': Adafruit_DHT.AM2302 }

if len(sys.argv) >= 2:
	pin = sys.argv[1]
else:
	sys.exit(1)

while True:
  humidity, temperature = Adafruit_DHT.read_retry(sensor_args['22'], pin)
  if humidity is not None and temperature is not None and 0 <= humidity <= 100.0:
    print '{1:0.1f},{0:0.1f}'.format(temperature, humidity)
    sys.exit(0)
  else:
    print >> sys.stderr, 'Failed to get reading. Try again'

sys.exit(1)

@@ -10,16 +10,17 @@
 n/python
+3
 %0A%0Aimport
@@ -120,18 +120,32 @@
 .DHT11,%0A
-%09%09
+                
 '22': Ad
@@ -166,10 +166,24 @@
 22,%0A
-%09%09
+                
 '230
@@ -232,17 +232,24 @@
 ) %3E= 2:%0A
-%09
+        
 pin = sy
@@ -268,9 +268,16 @@
 se:%0A
-%09
+        
 sys.
@@ -462,17 +462,17 @@
    print
- 
+(
 '%7B1:0.1f
@@ -512,16 +512,17 @@
 umidity)
+)
 %0A    sys
@@ -551,24 +551,9 @@
 rint
- %3E%3E sys.stderr, 
+(
 'Fai
@@ -582,16 +582,34 @@
 y again'
+, file=sys.stderr)
 %0A%0Asys.ex

switch to python3