python getopt functionality
hi; I have a perl script that I need to port to python. The script takes input from the command line. Is there a standard way of processing command line arguments based on the -flag preceeding the argument? thanks moe smadi -- http://mail.python.org/mailman/listinfo/python-list
Re: python getopt functionality
M.N.A.Smadi wrote: I have a perl script that I need to port to python. The script takes input from the command line. Is there a standard way of processing command line arguments based on the -flag preceeding the argument? http://docs.python.org/lib/module-getopt.html http://docs.python.org/lib/module-optparse.html /F -- http://mail.python.org/mailman/listinfo/python-list
Re: python getopt functionality
M.N.A.Smadi wrote: I have a perl script that I need to port to python. The script takes input from the command line. Is there a standard way of processing command line arguments based on the -flag preceeding the argument? Yes. # pydoc getopt Help on module getopt: NAME getopt - Parser for command line options. FILE /usr/lib/python2.4/getopt.py MODULE DOCS http://www.python.org/doc/current/lib/module-getopt.html [ ... snip ... ] Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: python getopt functionality
It is not clear to me if i can define `mandatory' options? That sounds strange but let say that the command `requires ' a value for -z or --zoo (either or should be find but one and only one of them MUST be present). Can i do that with resorting to using if statements? thanks moe smadi Fredrik Lundh wrote: M.N.A.Smadi wrote: I have a perl script that I need to port to python. The script takes input from the command line. Is there a standard way of processing command line arguments based on the -flag preceeding the argument? http://docs.python.org/lib/module-getopt.html http://docs.python.org/lib/module-optparse.html /F -- http://mail.python.org/mailman/listinfo/python-list
Re: python getopt functionality
On Oct 03, M.N.A.Smadi wrote: It is not clear to me if i can define `mandatory' options? That sounds strange but let say that the command `requires ' a value for -z or --zoo (either or should be find but one and only one of them MUST be present). Can i do that with resorting to using if statements? Optik (optparse) adheres to a Tao of Option Parsing http://optik.sourceforge.net/doc/1.5/tao.html, which discusses required option arguments. -- Micah Elliott -- http://mail.python.org/mailman/listinfo/python-list