[Biopython-dev] Bug in Bio.PDB?

João Rodrigues anaryin at gmail.com
Tue Feb 18 02:02:04 UTC 2014


Hi Morten,

This is not a "bug" per se, but a matter of changing the chain object while
you are iterating over it. You get the same effect with this loop:

>>> nums = [1,2,3,4,5,6,7,8,9,11,13,15]
>>> for i in nums:
...   if i % 2 == 0:
...     nums.remove(i)
...   print i,
...
1 2 4 6 8 11 13 15
​
The only options you have is to use chain.child_list (which does create a
copy of the list and it's safe to iterate on) or just save the ids to
remove and remove them a posteriori.

Cheers,

João




More information about the Biopython-dev mailing list