apardon at forel.vub.ac.be
Tue Jan 10 09:02:25 CET 2006
Op 2006-01-10, Bengt Richter schreef <bokr at oz.net>:
> On 9 Jan 2006 08:19:21 GMT, Antoon Pardon <apardon at forel.vub.ac.be> wrote:
>>Op 2006-01-05, Bengt Richter schreef <bokr at oz.net>:
>>> On 5 Jan 2006 15:48:26 GMT, Antoon Pardon <apardon at forel.vub.ac.be> wrote:
>>> But you can fix that (only test is what you see ;-) :
>>Maybe, but not with this version.
>>> >>> from itertools import repeat, chain, izip
>>> >>> it = iter(lambda z=izip(chain([3,5,8],repeat("Bye")), chain([11,22],repeat("Bye"))):z.next(), ("Bye","Bye"))
>>> >>> for t in it: print t
>>> (3, 11)
>>> (5, 22)
>>> (8, 'Bye')
>>> (Feel free to generalize ;-)
>>The problem with this version is that it will stop if for some reason
>>each iterable contains a 'Bye' at the same place. Now this may seem
>>far fetched at first. But consider that if data is collected from
> ISTM the job of choosing an appropriate sentinel involves making
> that not only far fetched but well-nigh impossible ;-)
>>experiments certain values may be missing. This can be indicated
>>by a special "Missing Data" value in an iterable. But this "Missing
>>Data" value would also be the prime canidate for a fill parameter
>>when an iterable is exhausted.
> ISTM that confuses "missing data" with "end of data stream."
"end of data stream" implies "missing data". If I'm doing experiments
with a number of materials under a number of tempertures and I want
to compare how copper, iron and lead behaved then when I compare
the results for 400 K and there is no data for lead, I don't care
whether that is because the measurement for 400K was somehow
lost or unsuable or because they stopped the lead measurements at 350K.
It all boils down to no data for lead at 400K, there is no need that
the processing unit differentiates beteen the different reasons for
the missing data. That difference is only usefull for the loop control.
> I assumed your choice of terminating sentinel ("Bye") would not have
> that problem ;-)
That is true, but what is adequate in one situation doesn't need to
be adequate in general.
More information about the Python-list