On Fri, Jan 27, 2012 at 4:20 PM, Andrew Dalke <[email protected]> wrote:
> As a style note,
>
> On Jan 26, 2012, at 11:00 AM, Greg Landrum wrote:
>> To answer your question, the following bit of code works:
>>
>> f = gzip.open('output.sdf.gz','w+')
>> w = Chem.SDWriter(f)
>> for m in ms: w.write(m)
>> w.flush()
>> f.flush()
>> w=None
>> f=None
>
> If you are running with Python 2.7 then a context-mangager solution might be 
> cleaner:
>
> with gzip.open('output.sdf.gz','w+') as f:
>  w = Chem.SDWriter(f)
>  for m in ms: w.write(m)
>  w.flush()
>  w = None
>

I haven't followed the evolution of context managers in Python; what's
the advantage?

>
> Consider that a request. :)

Duly noted. I will have to check if they are supported by boost.python.

-greg

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to