diff options
| author | Stan Seibert <stan@mtrr.org> | 2011-09-08 11:32:56 -0400 |
|---|---|---|
| committer | Stan Seibert <stan@mtrr.org> | 2011-09-08 11:32:56 -0400 |
| commit | aeb16cf530767cd16c23c258802325b726e577d7 (patch) | |
| tree | 17c5d62db8edeb47bb11dfdb3dc0e15421b80dd6 | |
| parent | bec629d6cb050164dc3b96c832a5e25f6840f754 (diff) | |
| download | chroma-aeb16cf530767cd16c23c258802325b726e577d7.tar.gz chroma-aeb16cf530767cd16c23c258802325b726e577d7.tar.bz2 chroma-aeb16cf530767cd16c23c258802325b726e577d7.zip | |
Prevent progress() from raising an exception if you pass in a sequence with less than 10 elements
| -rw-r--r-- | tools.py | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -13,8 +13,9 @@ def progress(seq): n = len(seq) print '[' + ' '*21 + ']\r[', sys.stdout.flush() + update_interval = max(n // 10, 1) for i, item in enumerate(seq): - if i % (n//10) == 0: + if i % update_interval == 0: print '.', sys.stdout.flush() yield item |
