Mercurial > pylearn
view common/str.py @ 362:00d57d3f33eb
Added common.misc.utilsdir
author | Joseph Turian <turian@iro.umontreal.ca> |
---|---|
date | Thu, 03 Jul 2008 00:14:42 -0400 |
parents | 9e73e6dc9823 |
children |
line wrap: on
line source
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)