[Tutor] optparse.OptionParser options in alphabetical order in help display
Steven D'Aprano
steve at pearwood.info
Wed Dec 19 02:13:18 CET 2012
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
More information about the Tutor
mailing list