From: DeLano S. <de...@de...> - 2008-02-15 17:31:36
|
In the current open-source and beta builds (1.1), pymol -c script.py -- arg1 arg2 should give a sys.argv of ['script.py', 'arg1', 'arg2'] paralleling the behavior of Python, given similar inputs: python script.py arg1 arg2 Cheers, Warren PS. the "3D" after the equals sign is annoying mailing list / MIME artifact. -- DeLano Scientific LLC Subscriber Support Services mailto:de...@de... > -----Original Message----- > From: pym...@li... > [mailto:pym...@li...] On Behalf > Of Michael Lerner > Sent: Friday, February 15, 2008 8:22 AM > To: Josep Maria Campanera Alsina > Cc: pym...@li... > Subject: Re: [PyMOL] Command-line arguments when using PyMOL > to launch ascript > > Hi, > > First, the initial error you were seeing was a syntax error: > > > from sys import argv > > my_argv =3D argv[argv.index("--"):] > > print my_argv[1], my_argv[2] > > is failing because of the word "3D" > > Second, that used to fail on Linux systems anyway (it worked > on some other systems). I tend to use optparse, which often > requires things to live in sys.argv. Here's my current workaround: > > #argv = sys.argv[sys.argv.index('--') + 1:] > try: > argv = sys.argv > except AttributeError: > argv = pymol_argv > sys.argv = pymol_argv # this is necessary for > optparse to handle the --help option. > try: > argv = argv[argv.index('--') + 1:] > except IndexError: > argv = [] > > options,args = parser.parse_args(args=argv) > > I haven't re-tested Linux recently, though. It might be that > the pymol_argv workaround is not necessary anymore. > > -michael > > -- > IRTA Postdoctoral Fellow > Laboratory of Computational Biology NIH/NHLBI > 5635 Fishers Lane, Room T909 > http://www.umich.edu/~mlerner > > -------------------------------------------------------------- > ----------- > This SF.net email is sponsored by: Microsoft Defy all > challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > PyMOL-users mailing list > PyM...@li... > https://lists.sourceforge.net/lists/listinfo/pymol-users |