Software: Apache/2.0.54 (Unix) mod_perl/1.99_09 Perl/v5.8.0 mod_ssl/2.0.54 OpenSSL/0.9.7l DAV/2 FrontPage/5.0.2.2635 PHP/4.4.0 mod_gzip/2.0.26.1a uname -a: Linux snow.he.net 4.4.276-v2-mono-1 #1 SMP Wed Jul 21 11:21:17 PDT 2021 i686 uid=99(nobody) gid=98(nobody) groups=98(nobody) Safe-mode: OFF (not secure) /opt/doc/python-2.3.4/html/Python-Docs-2.3.4/lib/ drwxr-xr-x | |
| Viewing file: Select action/file-type:
|
| Action | Meaning |
|---|---|
store |
store this option's argument (default) |
store_const |
store a constant value |
store_true |
store a true value |
store_false |
store a false value |
append |
append this option's argument to a list |
count |
increment a counter by one |
callback |
call a specified function |
help |
print a usage message including all options and the documentation for them |
(If you don't supply an action, the default is ``store''. For this action, you may also supply type and dest keywords; see below.)
As you can see, most actions involve storing or updating a value somewhere. optparse always creates a particular object (an instance of the Values class) specifically for this purpose. Option arguments (and various other values) are stored as attributes of this object, according to the dest (destination) argument to make_option()/add_option().
For example, when you call:
parser.parse_args()
one of the first things optparse does is create a
values object:
values = Values()
If one of the options in this parser is defined with:
make_option("-f", "--file", action="store", type="string", dest="filename")
and the command-line being parsed includes any of the following:
-ffoo -f foo --file=foo --file foo
then optparse, on seeing the -f or --file option, will do the equivalent of this:
values.filename = "foo"
Clearly, the type and dest arguments are almost as important as action. action is the only attribute that is meaningful for all options, though, so it is the most important.
See About this document... for information on suggesting changes.
:: Command execute :: | |
--[ c99shell v. 1.0 pre-release build #13 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0045 ]-- |