[Tutor] optparse.OptionParser options in alphabetical order in help display
rail shafigulin
rail.shafigulin at gmail.com
Wed Dec 19 02:42:15 CET 2012
On Tue, Dec 18, 2012 at 8:13 PM, Steven D'Aprano <steve at pearwood.info>wrote:
> On 19/12/12 07:39, rail shafigulin wrote:
>
> I currently have it done this way. It just seems a bit odd that I have to
>> arrange it manually.
>>
>
> What's so special about alphabetical order? Wouldn't it make more sense for
> related options to be kept together?
>
> E.g.:
>
> Usage: make_sandwich [OPTIONS]
>
> --bread KIND white, multigrain, rye, black, sourdough or
> wholemeal.
> --style "light"|"dark" Defaults to "light" if not given. Ignored
> unless bread=rye.
> --meat KIND chicken, ham, turkey, pastrami, salami, spam
> or beef
>
> rather than:
>
> --bread KIND white, multigrain, rye, black, sourdough or
> wholemeal.
> --meat KIND chicken, ham, turkey, pastrami, salami, spam
> or beef
> --style "light"|"dark" Defaults to "light" if not given. Ignored
> unless bread=rye.
>
>
> Obviously with only three options it doesn't make much difference, but
> suppose
> you had two dozen options. Alphabetical order means that related options
> will be
> scattered all over the place.
>
>
>
> --
> Steven
> ______________________________**_________________
>
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
There is nothing special about alphabetical order. You are right, it is
better to arrange related options together. For my script, I don't have
related options and simply want to arrange them in alphabetical order.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121218/7d040d07/attachment.html>
More information about the Tutor
mailing list