!C99Shell v. 1.0 pre-release build #13!

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
Free 318.32 GB of 458.09 GB (69.49%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     optparse-store-action.html (8.33 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
6.20.2.1 The store action


6.20.2.1 The store action

The action tells optparse what to do when it sees one of the option strings for this option on the command-line. For example, the action store means: take the next argument (or the remainder of the current argument), ensure that it is of the correct type, and store it to your chosen destination.

For example, let's fill in the ``...'' of that last option:

parser.add_option("-f", "--file",
                  action="store", type="string", dest="filename")

Now let's make up a fake command-line and ask optparse to parse it:

args = ["-f", "foo.txt"]
(options, args) = parser.parse_args(args)

(Note that if you don't pass an argument list to parse_args(), it automatically uses sys.argv[1:].)

When optparse sees the -f, it consumes the next argument--foo.txt--and stores it in the filename attribute of a special object. That object is the first return value from parse_args(), so:

print options.filename

will print foo.txt.

Other option types supported by optparse are int and float. Here's an option that expects an integer argument:

parser.add_option("-n", type="int", dest="num")

This example doesn't provide a long option, which is perfectly acceptable. It also doesn't specify the action--it defaults to ``store''.

Let's parse another fake command-line. This time, we'll jam the option argument right up against the option, since -n42 (one argument) is equivalent to -n 42 (two arguments).

(options, args) = parser.parse_args(["-n42"])
print options.num

This prints 42.

Trying out the ``float'' type is left as an exercise for the reader.

If you don't specify a type, optparse assumes ``string''. Combined with the fact that the default action is ``store'', that means our first example can be a lot shorter:

parser.add_option("-f", "--file", dest="filename")

If you don't supply a destination, optparse figures out a sensible default from the option strings: if the first long option string is --foo-bar, then the default destination is foo_bar. If there are no long option strings, optparse looks at the first short option: the default destination for -f is f.

Adding types is fairly easy; please refer to section 6.20.5, ``Adding new types.''

See About this document... for information on suggesting changes.

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 1.0 pre-release build #13 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.004 ]--