Opened 3 years ago

#8866 defect new

Options.getUsage inconsistently orders options

Reported by: Gavin Panella Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:
Author:

Description

Run the following script a few times and observe the changing order of options. It also hints at a simple fix for the problem.

from twisted.python import usage

class UnsortedOptions(usage.Options):

    def opt_one(self):
        pass

    def opt_two(self):
        pass

class SortedOptions(usage.Options):

    def __init__(self):
        super(SortedOptions, self).__init__()
        self.longOpt.sort()

    def opt_one(self):
        pass

    def opt_two(self):
        pass

unsortedOptions = UnsortedOptions()
print("== UNSORTED ==")
print(unsortedOptions.getUsage())

sortedOptions = SortedOptions()
print("== SORTED ==")
print(sortedOptions.getUsage())

Change History (0)

Note: See TracTickets for help on using tickets.