[FRPythoneers] dispatching from a script

Greg Holling greg at holling-co.com
Fri Apr 15 16:16:08 MDT 2011


The argparse sub-commands functionality is pretty slick.  It looks to me you could accomplish the same basic purpose with OptionParser.add_option(), which calls a callback for each command-line option.

Greg

On Apr 15, 2011, at 2:42 PM, Brent Pedersen wrote:

> On Fri, Apr 15, 2011 at 2:36 PM, Greg Holling <greg at holling-co.com> wrote:
>> You can do the same thing with optparse in older versions of Python (deprecated and replaced with argparse in 2.7):
>> 
>> http://docs.python.org/library/optparse.html
>> 
>> Greg
>> 
>> On Apr 15, 2011, at 12:19 PM, Ian Kelly wrote:
>> 
>>> On Fri, Apr 15, 2011 at 11:44 AM, Brent Pedersen <bpederse at gmail.com> wrote:
>>>> thanks, that does what i want:
>>>> http://docs.python.org/dev/library/argparse.html#sub-commands
>>>> just looks like it's not even in the 2.7 stdlib, so i'll add it as a dependency.
>>> 
>>> It's in 2.7 and 3.2, and for other versions it's available from Google Code.
>>> 
>>> Cheers,
>>> Ian
>>> _______________________________________________
>>> This message sent by the FRPythoneers mailing list.
>>> Unsubscribe: echo unsubscribe | FRPythoneers-request at lists.community.tummy.com
>>> URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers
>> 
>> _______________________________________________
>> This message sent by the FRPythoneers mailing list.
>> Unsubscribe: echo unsubscribe | FRPythoneers-request at lists.community.tummy.com
>> URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers
>> 
> 
> but then you still have to dispatch manually, correct?
> _______________________________________________
> This message sent by the FRPythoneers mailing list.
> Unsubscribe: echo unsubscribe | FRPythoneers-request at lists.community.tummy.com
> URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers




More information about the FRPythoneers mailing list