> But in the meantime, as a workaround, fall back on __main__.pymol_argv if > sys.argv is not defined.
Thanks! For what it's worth, I ended up with something like try: args = sys.argv except AttributeError: sys.argv = pymol_argv args = sys.argv because I'm using optparse to handle command line options. When optparse generates its automatic help messages, it calls through to sys.argv no matter what you tell it to do. Here's a related question: when I call sys.exit from my script (or, actually, when optparse calls it), it ends up causing a traceback. Is there any way to turn that behavior off? At the moment, I'm using this as a workaround: from pymol import cmd import sys def exit(*args,**kwargs): cmd.quit() sys.exit = exit but I thought that I remembered hearing about a better way once. Thanks, -michael > > Cheers, > Warren > > > > -- > DeLano Scientific LLC > Subscriber Support Services > mailto:del...@delsci.info > > "Not yet a PyMOL Subscriber, but want to support the project? Email > sa...@delsci.com to quote your lab, school, or employer. Thank you for > sponsoring this open-source endeavor!" -WLD > > > > -----Original Message----- > > From: pymol-users-boun...@lists.sourceforge.net > > [mailto:pymol-users-boun...@lists.sourceforge.net] On Behalf > > Of Michael Lerner > > Sent: Tuesday, August 14, 2007 2:35 PM > > To: pymol-users@lists.sourceforge.net > > Subject: [PyMOL] Why can't I get to sys.argv on Linux? > > > > Hi, > > > > I'm using PyMOL as a front end to a few scripts. So, I need > > to get my hands on sys.argv to process the command-line > > arguments. On OS X, everything works just like I'd expect. > > However, on Linux, I can't get sys.argv. Here's a very simple > > Python script: > > > > #!/usr/bin/env python > > import sys > > print dir(sys) > > print sys.argv > > > > When I run pymol -cr ./my_script.py on Linux, I get this: > > > > PyMOL>run ./x.py,main > > ['__displayhook__', '__doc__', '__excepthook__', '__name__', > > '__stderr__', '__stdin__', '__stdout__', '_getframe', > > 'api_version', 'builtin_module_names', 'byteorder', > > 'call_tracing', 'callstats', 'copyright', 'displayhook', > > 'exc_clear', 'exc_info', 'exc_type', 'excepthook', > > 'exec_prefix', 'executable', 'exit', 'exitfunc', > > 'getcheckinterval', 'getdefaultencoding', 'getdlopenflags', > > 'getfilesystemencoding', 'getrecursionlimit', 'getrefcount', > > 'hexversion', 'maxint', 'maxunicode', 'meta_path', 'modules', > > 'path', 'path_hooks', 'path_importer_cache', 'platform', > > 'prefix', 'setcheckinterval', 'setdlopenflags', 'setprofile', > > 'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', > > 'version', 'version_info', 'warnoptions'] Traceback (most > > recent call last): > > File "/users/mlerner/src/pymol/modules/pymol/parser.py", > > line 287, in parse > > > > parsing.run_file(exp_path(args[nest][0]),__main__.__dict__,__m > > ain__.__dict__) > > File "/users/mlerner/src/pymol/modules/pymol/parsing.py", > > line 407, in run_file > > execfile(file,global_ns,local_ns) > > File "./x.py", line 4, in ? > > print sys.argv > > AttributeError: 'module' object has no attribute 'argv' > > PyMOL: normal program termination. > > > > While pawing around in the PyMOL sources, I found that > > pymol_argv shows up. It seems to be what I want, but I don't > > know how stable it is. Am I supposed to use it instead of sys.argv? > > > > Thanks, > > > > -michael > > > > -- > > Biophysics Graduate Student > > Carlson Lab, University of Michigan > > http://www.umich.edu/~mlerner > > > > -------------------------------------------------------------- > > ----------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and > > a browser. > > Download your FREE copy of Splunk now >> > > http://get.splunk.com/ _______________________________________________ > > PyMOL-users mailing list > > PyMOL-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/pymol-users > >