Importing constantly changing variables

ariklapid.swim at gmail.com ariklapid.swim at gmail.com
Sat Dec 26 10:14:36 EST 2015


Hello everyone !
First of all, excuse me for my horrible English.

I am an electronics engineering student, trying to use raspberry pi for one of my projects.
Meanwhile, my goal is simply to create a pair of files, written in python, which would do the following:

A file named "sensors.py" imports varying values from physical sensors. These values are constantly changing. 
(At this point - I intend to change them manually):

[code]
def import_soilMoisture():
	soilMoisture = 40 # Later - Imports value from corresponding RPi's GPIO
	return soilMoisture

def import_airTemperture():
	airTemperture = 24 # Later - Imports value from corresponding RPi's GPIO
	return airTemperture

def import_airHumidity():
	airHumidity = 69 # Later - Imports value from corresponding RPi's GPIO
	return airHumidity
[/code]

A second file, named "main.py" is intended to import and print the values from "sensors.py":

[code]
import time

def main():
	while True:
		import sensors
		print(sensors.import_soilMoisture())
		print(sensors.import_airTemperture())
		print(sensors.import_airHumidity())
		time.sleep(5)
main()
[/code]

As you can see, I want the program to print all values each 5 seconds.
When I run the file "main.py" it does print values every 5 seconds, BUT when I manually change
the values (e.g. airTemperture = 30 instead of 24) and save the file, nothing changes - 
the old values keep on printing.

[b]Help me please to understand what's wrong[/b]
[i]For who it may concern: My OS is Debian[/i]

Thanks to you all in advance!! :) :D



More information about the Python-list mailing list