467,161 Members | 868 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

optparse bug?

Hi,

I'm getting a conflict between options defined between two different
scripts and I'm wondering if it is a bug or the intended effect.

script foo:

<def some_function>
<define some options with optparse functionality>

script bar:

from foo import some_function
<define options for bar script>

When I do ./bar --help I get foo's options! This is fixed by rewriting
bar.py so the import from foo occurs after parsing bar's options:

from optparse import OptionParser
<define options for bar script>
options, args = parser.parse_args()

from foo import some_function

This is mildly annoying behavior. Do I really have to reorder my import
statements to avoid importing options from other scripts?

Andres Corrada-Emmanuel
Senior Research Fellow
Center for Intelligent Information Retrieval
University of Massachusetts, Amherst
Jul 18 '05 #1
  • viewed: 1287
Share:
1 Reply
Andres Corrada-Emmanuel wrote:
I'm getting a conflict between options defined between two different
scripts and I'm wondering if it is a bug or the intended effect.


Neither. I'm pretty sure that you somehow managed to add all options to a
single OptionParser instance. Do you know about the

if __name__ == "__main__":
# code to run only in standalone mode

technique? For a more detailed analysis you have to provide the actual code
of a minimal example.

Peter

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Hans-Joachim Widmaier | last post: by
7 posts views Thread by Henry Ludemann | last post: by
5 posts views Thread by Norbert Thek | last post: by
3 posts views Thread by Karlo Lozovina | last post: by
3 posts views Thread by Bob | last post: by
reply views Thread by Steven Bethard | last post: by
2 posts views Thread by mbeachy@gmail.com | last post: by
reply views Thread by Robert Kern | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.