optparse: Why does this syntax work and not another?
Anthony Baxter
anthonybaxter at gmail.com
Mon Jul 5 02:49:02 EDT 2004
More information about the Python-list mailing list
Mon Jul 5 02:49:02 EDT 2004
- Previous message (by thread): optparse: Why does this syntax work and not another?
- Next message (by thread): optparse: Why does this syntax work and not another?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, 05 Jul 2004 06:36:46 GMT, washu <me at privacy.net> wrote: > And everything works. It will print foo.txt. Now, instead of doing the > parser = optparse.OptionParser() substitution, I spell everything out: > > optparse.OptionParser().add_option( . . .) > (options, args) = optparse.OptionParser().parse_args( . . . ) > And the script stops with an error message of: "no such option: -f" Because your code is incorrect. The first of these two lines creates and OptionParser() instance, and calls 'add_option()' on it. It then throws away the newly created instance, as you didn't assign it to anything.
- Previous message (by thread): optparse: Why does this syntax work and not another?
- Next message (by thread): optparse: Why does this syntax work and not another?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list