http://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile
Quote: "If delete is true (the default), the file is deleted as soon as
it is closed."
Cheers,
Thomas
Boris Kheyfets wrote, On 01/23/13 14:47:
> It prints the selection all right. Why then save wouldn't save it:
>
>
> def bk_saves_unique_pdb(Selection = None):
> """Takes current selection (or "all" -- if nothing selected) and saves it
> as a uniquetly named pdb file (Frame_Selection_RandomString.pdb) in the
> current working directory."""
> if not Selection:
> Selection = cmd.get_names('selections', 1)
> if Selection:
> Selection = Selection[0] # it was a list
> else:
> Selection = 'all'
> tempFile = tempfile.NamedTemporaryFile(dir=os.curdir,
> prefix="{frame:03d}_{sel}_".format(frame=cmd.get_frame(), sel=Selection) ,
> suffix=".pdb")
> print tempFile.name, Selection # prints righteous file name and selection
> name (though not in quotes)
> cmd.save(tempFile.name, Selection) # but still saves nothing
> cmd.extend("bk_saves_unique_pdb", bk_saves_unique_pdb)
--
Thomas Holder
PyMOL Developer
Schrödinger Contractor
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
PyMOL-users mailing list ([email protected])
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/[email protected]