I want to keep a list of temperature probes that will be taking temperature readings periodically. I want to store the arguments needed to create each instance of the temperature probe object in a list of lists. I then want to create each instance from this list of lists and name each object using index 0 of each nested list.
For example, I want the instances Probe1, Probe2, and Probe3 created with their corresponding arguments. I then want to take a temperature reading from each probe in the list.
I want to be able to add unlimited probes without having to change the code down the line.
The issue I'm running into is when I try and do anything with Probe1, Probe2, or Probe3 python tells me they don't exist. I'm new to programming and I'm sure I'm missing something obvious.
class max31865(object):
def __init__(self, name, R_REF, csPin):
self.name = name
self.R_REF = R_REF
self.csPin = csPin
def readTemp(self):
#code here to check temp
probe_list=[["Probe1", 430, 8],["Probe2", 430, 9],["Probe3", 430, 10]]
for probe in probe_list:
x = str(probe[0])
x = max31865(*probe)
for probe in probe_list:
readTemp(probe[0])
xvariable, so you basically lose all previously instantiated objects ofmax31865. Second, you are trying to callreadTemp, which is a method defined in yourmax31865class, from an outer scope, which is not possible. I am not sure what you are trying to accomplish here