Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100894

Importing constantly changing variables

Newsgroups comp.lang.python
Date 2015-12-26 07:14 -0800
Message-ID <944a9d35-dc31-4074-8d56-bb6e9a0d1d15@googlegroups.com> (permalink)
Subject Importing constantly changing variables
From ariklapid.swim@gmail.com

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Importing constantly changing variables ariklapid.swim@gmail.com - 2015-12-26 07:14 -0800
  Re: Importing constantly changing variables Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-26 10:11 -0700
  Re: Importing constantly changing variables Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-12-26 13:14 -0500
  Re: Importing constantly changing variables Ben Finney <ben+python@benfinney.id.au> - 2015-12-27 10:15 +1100

csiph-web