From c9d9769f8373f64e027f3e041fd16c412f76b19a Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 20 Mar 2012 11:59:33 -0400 Subject: [PATCH] comment on a non-obvious function --- .../python_algorithms.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py b/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py index ccee8185d..894c5212e 100644 --- a/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py +++ b/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py @@ -35,6 +35,12 @@ def strategy_byparents(sequence): """ def partindices(item): + """Convert an entry a tuple of the indices of the entry's parts. + + >>> sequence = testsequence + >>> assert partindices("c/2/x") == (sequence.index("c"), sequence.index("c/2"), sequence.index("c/2/x")) + fnord + """ return tuple(sequence.index(item.rsplit('/', i)[0]) for i in range(item.count('/'), -1, -1)) return sorted(sequence, key=partindices) -- 2.26.2