Python List Comprehensions Help

This is why I recommend looking at the tag quality.
In my example I have three tags, ‘Tag 01, Tag 02, and Tag 04’. The processing portion only pays attention to those qualities that are good.
image

numberOfTags = 4
baseTagPath  = '[Test]Tag {0:02d}'

tagPaths = [baseTagPath.format(i) for i in xrange(1, numberOfTags+1)]
valuesIn = system.tag.readBlocking(tagPaths)

print 'Tags In'
for tag, qVal in zip(tagPaths, valuesIn):
	print tag, ':', qVal

# Processing
tagsOut = []
valuesOut = []

for tag, qValue in zip(tagPaths, valuesIn):
	if 'Good' in str(qValue.quality):
		tagsOut.append(tag)
		valuesOut.append(qValue.value + 5)
		
print 'Tags Out'
for tag, val in zip(tagsOut, valuesOut):
	print tag, ':', val
numberOfTags = 4
baseTagPath  = '[Test]Tag {0:02d}'

tagPaths = [baseTagPath.format(i) for i in xrange(1, numberOfTags+1)]
valuesIn = system.tag.readBlocking(tagPaths)

print 'Tags In'
for tag, qVal in zip(tagPaths, valuesIn):
	print tag, ':', qVal

# Processing
tagsOut = []
valuesOut = []
for tag, qValue in zip(tagPaths, valuesIn):
	if 'Good' in str(qValue.quality):
		tagsOut.append(tag)
		valuesOut.append(qValue.value + 5)
print '\n-----------\n\nTags Out'		
for tag, val in zip(tagsOut, valuesOut):
	print tag, ':', val

Output

>>> 
Tags In
[Test]Tag 01 : [10, Good, Mon Feb 28 15:11:26 EST 2022 (1646079086152)]
[Test]Tag 02 : [20, Good, Mon Feb 28 15:11:28 EST 2022 (1646079088784)]
[Test]Tag 03 : [null, Bad_NotFound("Path '[Test]Tag 03' not found."), Wed Feb 16 12:47:37 EST 2022 (1645033657329)]
[Test]Tag 04 : [40, Good, Mon Feb 28 16:05:57 EST 2022 (1646082357934)]

-----------

Tags Out
[Test]Tag 01 : 15
[Test]Tag 02 : 25
[Test]Tag 04 : 45
>>> 
1 Like