# HG changeset patch # User Joseph Turian # Date 1213907222 14400 # Node ID 2291a244a887369785983b082b100604d5023f66 # Parent 18702ceb2096038b2e896ef03b64aba7758a45db Added common.string diff -r 18702ceb2096 -r 2291a244a887 common/misc.py --- a/common/misc.py Thu Jun 19 16:18:37 2008 -0400 +++ b/common/misc.py Thu Jun 19 16:27:02 2008 -0400 @@ -10,12 +10,6 @@ return +1 if i > 0 else -1 -def percent_string(a, b): - assert a <= b - assert a >= 0 - assert b > 0 - return "%s of %s (%.2f%%)" % (a, b, 100.*a/b) - def unique_elements_list_intersection(list1,list2): """ Return the unique elements that are in both list1 and list2 diff -r 18702ceb2096 -r 2291a244a887 common/string.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/string.py Thu Jun 19 16:27:02 2008 -0400 @@ -0,0 +1,9 @@ +def percent(a, b): + """ + Return percentage string of a and b, e.g.: + "1 of 10 (10%)" + """ + assert a <= b + assert a >= 0 + assert b > 0 + return "%s of %s (%.2f%%)" % (a, b, 100.*a/b)