Revision 976
Added by Aaron Marcuse-Kubitza almost 13 years ago
lib/util.py | ||
---|---|---|
28 | 28 |
|
29 | 29 |
def is_str(val): return isinstance(val, basestring) |
30 | 30 |
|
31 |
#### Strings |
|
32 |
|
|
33 |
def to_percent(val, sig_figs=2): |
|
34 |
if val >= 1: sig_figs += 1 |
|
35 |
return (('%#.'+str(sig_figs)+'g') % (val*100))+'%' |
|
36 |
|
|
31 | 37 |
#### Iterables |
32 | 38 |
|
33 | 39 |
def first(iter_): return iter_.next() |
Also available in: Unified diff
util.py: Added to_percent()