import logging logging.basicConfig(level=logging.INFO) def time_to_log(data, percent=10): percent = percent if percent > 1 else percent * 100 data_size = len(data) log_every = data_size * percent / 100 return float(data_size), lambda i: not i % log_every data = range(100) data_size, is_time_to_log = time_to_log(data, 0.2) for i, d in enumerate(data): if is_time_to_log(i): logging.info("processing... {:.2%}".format(i / data_size)) pass # do whatever is needed logging.info("processing... 100.00%")
here I will gather some notes on my python use. I will give my impressions on different libs when I can give them a try to solve the problem at hand. Also I will announce some releases when I think some of my packages might be useful to others.
Search This Blog
12 October 2015
Output a log message every x% of a long computation
10 October 2015
another reader's digest
The borg pattern
Neural network, 11 LOC
Best practices
to manage a Python code library
0x5f3759df
Another magic number
comprendo comprehension ?
Youtube File System
A peek in the future
Print
>>> print
>>> from __future__ import print_function
>>> print
<built-in function print>
division
>>> 3/2
1
>>> from __future__ import division
>>> 3/2
1.5
Hold your brace
>>> from __future__ import braces
SyntaxError: not a chance (<input>, line 1)
Subscribe to:
Posts (Atom)