comparison common/string.py @ 357:2291a244a887

Added common.string
author Joseph Turian <turian@iro.umontreal.ca>
date Thu, 19 Jun 2008 16:27:02 -0400
parents common/misc.py@430c9e92cd23
children
comparison
equal deleted inserted replaced
356:18702ceb2096 357:2291a244a887
1 def percent(a, b):
2 """
3 Return percentage string of a and b, e.g.:
4 "1 of 10 (10%)"
5 """
6 assert a <= b
7 assert a >= 0
8 assert b > 0
9 return "%s of %s (%.2f%%)" % (a, b, 100.*a/b)