how to iterate over sequence and non-sequence ?
stef.mientki at gmail.com
Fri Oct 19 01:24:09 CEST 2007
I generate dynamically a sequence of values,
but this "sequence" could also have length 1 or even length 0.
So I get some line in the form of:
line = '(2,3,4)'
line = ''
line = '(2)'
(in fact these are not constant numbers, but all kind of integer
variables, coming from all over the program, selected from a tree, that
shows all "reachable" variables)
So in fact I get the value from an exec statement, like this
exec 'signals = ' + line
Now I want to iterate over "signals", which works perfect if there are 2
or more signals,
but it fails when I have none or just 1 signal.
for value in signals :
As this meant for real-time signals, I want it fast, so (I think) I
can't afford extensive testing.
Any smart solution there ?
More information about the Python-list