# HG changeset patch # User Neal Fultz # Date 1561447307 0 # Node ID 83fe4c7e8702961806804d0bc9cd94dcf4e3365b # Parent b183c1d51530d9e85d4d830831babaf3c5a08c03 simplify exact prefix match diff -r b183c1d51530 -r 83fe4c7e8702 t.py --- a/t.py Mon Jan 01 10:37:56 2018 +1100 +++ b/t.py Tue Jun 25 07:21:47 2019 +0000 @@ -165,12 +165,10 @@ return self.tasks[matched[0]] elif len(matched) == 0: raise UnknownPrefix(prefix) + elif prefix in matched: + return self.tasks[prefix] else: - matched = [tid for tid in self.tasks.keys() if tid == prefix] - if len(matched) == 1: - return self.tasks[matched[0]] - else: - raise AmbiguousPrefix(prefix) + raise AmbiguousPrefix(prefix) def add_task(self, text): """Add a new, unfinished task with the given summary text."""