On Thu, Jul 1, 2010 at 9:01 PM, Noel O'Boyle <[email protected]> wrote: >> >> I think what you want is something like the following: >> >> suppl1 = Chem.SDMolSupplier('file1.sdf') >> suppl2 = Chem.SDMolSupplier('file2.sdf') >> >> for mol1 in suppl1: >> mol2 = suppl2.next() >> # do something with the two molecules > > Maybe "for mol1, mol2 in zip(suppl1, suppl2):" ? >
That's a really nice and clean way of spelling it, but a bit of a disaster when the files are large: zip(a,b) creates the whole joined list at once, it's not a generator (at least with python 2.5). What this means to those of you who don't get excited about these things is that Noel's form reads all the molecules from both suppliers into memory and then loops over them. The form I originally proposed only has two molecules in memory at a time. Best Regards, -greg ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Rdkit-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

