Dennis> So far as I understand, the
Dennis> global
Dennis> is not needed for your example.
I think the original context was that optparse was being used in the context
of a function.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Thanks. It works.
-Ashton
--
http://mail.python.org/mailman/listinfo/python-list
Ashton> This does not seem to work. I still get the default value
Ashton> 5007...
Hmmm... Works for me (Python from CVS):
% python testme.py
5007
% python testme.py -p 5006
5006
% python testme.py -p5006
5006
The only change from what you posted was to add
This does not seem to work. I still get the default value 5007 when i
run
$python txd.py - p5006
$python testme.py
***txd.py***
global options
parser = OptionParser()
parser.add_option("-p", "--port", dest="port", default=5007,
type="int",
help="port to
Ashton> How do i make an option passed through command line, using
Ashton> optparse global. I need to import this value in another file.
Place the parser's output at the module scope.
global options
parser = OptionParser()
parser.add_option("-p", "--port", dest="port", defaul