Show More
@@ -204,25 +204,16 b'' | |||
|
204 | 204 | "collapsed": true, |
|
205 | 205 | "input": [ |
|
206 | 206 | "import sys, time\n", |
|
207 | "try:\n", | |
|
208 | " from IPython.display import clear_output\n", | |
|
209 | " have_ipython = True\n", | |
|
210 | "except ImportError:\n", | |
|
211 | " have_ipython = False\n", | |
|
212 | 207 | "\n", |
|
213 | 208 | "class ProgressBar:\n", |
|
214 | 209 | " def __init__(self, iterations):\n", |
|
215 | 210 | " self.iterations = iterations\n", |
|
216 | 211 | " self.prog_bar = '[]'\n", |
|
217 | 212 | " self.fill_char = '*'\n", |
|
218 |
" self.width = |
|
|
213 | " self.width = 50\n", | |
|
219 | 214 | " self.__update_amount(0)\n", |
|
220 | " if have_ipython:\n", | |
|
221 | " self.animate = self.animate_ipython\n", | |
|
222 | " else:\n", | |
|
223 | " self.animate = self.animate_noipython\n", | |
|
224 | 215 | "\n", |
|
225 |
" def animate |
|
|
216 | " def animate(self, iter):\n", | |
|
226 | 217 | " print '\\r', self,\n", |
|
227 | 218 | " sys.stdout.flush()\n", |
|
228 | 219 | " self.update_iteration(iter + 1)\n", |
@@ -254,19 +245,12 b'' | |||
|
254 | 245 | "input": [ |
|
255 | 246 | "p = ProgressBar(1000)\n", |
|
256 | 247 | "for i in range(1001):\n", |
|
248 | " time.sleep(0.002)\n", | |
|
257 | 249 | " p.animate(i)" |
|
258 | 250 | ], |
|
259 | 251 | "language": "python", |
|
260 | 252 | "metadata": {}, |
|
261 | 253 | "outputs": [] |
|
262 | }, | |
|
263 | { | |
|
264 | "cell_type": "code", | |
|
265 | "collapsed": false, | |
|
266 | "input": [], | |
|
267 | "language": "python", | |
|
268 | "metadata": {}, | |
|
269 | "outputs": [] | |
|
270 | 254 | } |
|
271 | 255 | ], |
|
272 | 256 | "metadata": {} |
General Comments 0
You need to be logged in to leave comments.
Login now