Tim N. van der Leeuw wrote:
> Andrew Robert wrote:
>> Hi Everyone.
>>
>>
>> I tried the following to get input into optionparser from either a file
>> or command line.
>>
>>
>> The code below detects the passed file argument and prints the file
>> contents but the individual swithces do not get passed to option parser.
>>
> 
> After reading your post I decided to play around with optparse a bit,
> to get acquainted with it.
> 
> Experimenting with IDLE I found that the Values object returned by
> parse_args has a method 'readfile', and this 'readfile' method allows
> you to add options to the Values object.
> 
> The syntax should be in the form:
> 
> <option>=<value>
> 
> <option> should not include the hyphens -- if your option is added as
> '-x', then you should write:
> 
> x=3
> 
> not:
> 
> -x=3
> 
> If you have options with both long names and short names, then you
> should use the long name -- if your option is added as '-f', '--file',
> then you should write:
> 
> file=foo.txt
> 
> not:
> 
> f=foo.txt
> 
> 
> Also, you need the assignment-operator in your file.
> 
> I didn't find any documentation on this, and I didn't try this with any
> actions; only with options added to the parser like
> op.add_option('-x', dest='x')
> 
> Using this 2-step approach allows you to use optparse itself to get to
> the command-line option with your command-line settings...
> 
> 
> Out of pure personal interest, what queuing-system are you writing to
> from Python? What libraries do you have for that? And is it commercial
> software, or freely downloadable?
> (I'd love to be able to write messages to IBM MQ Series from Python)
> 
> Cheers,
> 
> --Tim
> 
Hi Tim,

I am using the pymqi module which is freely available at
http://pymqi.sourceforge.net/ .

Documentation on the module can be found at
http://pymqi.sourceforge.net/pymqidoc.html .

I have a few python examples on my web site located at
http://home.townisp.com/~arobert/

There are also a lot of good examples at
http://www.koders.com/info.aspx?c=ProjectInfo&pid=TVM5FGBZMY4E5ZH7GC9AX54PAC
.

If you come up with anything, I would be glad to see what you have.


Back to the original issue:

I'm not sure exactly what you mean about the readfile option and format.

Could you send me a code snippet so I can get a better feel for it?


Thanks,
Andy
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to