diff options
author | Lorrin Nelson <lhn_github@nerdylorrin.net> | 2010-11-22 11:22:16 -0800 |
---|---|---|
committer | Lorrin Nelson <lhn_github@nerdylorrin.net> | 2010-11-22 11:22:16 -0800 |
commit | c1862ca710baedd9313d805be261eeab6f7867e6 (patch) | |
tree | 4da970d210693e1ff93224c24d4fb1bade14e0d1 | |
parent | df99791c9d0769258144dcbb88ed96b9f79510d8 (diff) | |
parent | e2d4e208a2b79aefb907afe6f153c6bad8d912b4 (diff) | |
download | data_hacks-c1862ca710baedd9313d805be261eeab6f7867e6.zip data_hacks-c1862ca710baedd9313d805be261eeab6f7867e6.tar.gz data_hacks-c1862ca710baedd9313d805be261eeab6f7867e6.tar.bz2 |
Merge branch 'master' of https://github.com/bitly/data_hacks
-rw-r--r-- | data_hacks/bar_chart.py | 5 | ||||
-rw-r--r-- | data_hacks/histogram.py | 5 | ||||
-rw-r--r-- | data_hacks/ninety_five_percent.py | 5 | ||||
-rw-r--r-- | data_hacks/run_for.py | 7 | ||||
-rw-r--r-- | data_hacks/sample.py | 5 |
5 files changed, 6 insertions, 21 deletions
diff --git a/data_hacks/bar_chart.py b/data_hacks/bar_chart.py index 9bebc4c..33aa0ab 100644 --- a/data_hacks/bar_chart.py +++ b/data_hacks/bar_chart.py @@ -24,10 +24,7 @@ from collections import defaultdict from optparse import OptionParser def load_stream(input_stream): - while True: - line = input_stream.readline() - if not line: - break + for line in input_stream: clean_line = line.strip() if not clean_line: # skip empty lines (ie: newlines) diff --git a/data_hacks/histogram.py b/data_hacks/histogram.py index a4a2dc5..cc3339f 100644 --- a/data_hacks/histogram.py +++ b/data_hacks/histogram.py @@ -72,10 +72,7 @@ def test_mvsd(): assert '%.14f' % mvsd.sd() == "2.87228132326901" def load_stream(input_stream): - while True: - line = input_stream.readline() - if not line: - break + for line in input_stream: clean_line = line.strip() if not clean_line: # skip empty lines (ie: newlines) diff --git a/data_hacks/ninety_five_percent.py b/data_hacks/ninety_five_percent.py index 56dfc3e..66f6124 100644 --- a/data_hacks/ninety_five_percent.py +++ b/data_hacks/ninety_five_percent.py @@ -27,10 +27,7 @@ from decimal import Decimal def run(): count = 0 data = {} - while True: - line = sys.stdin.readline() - if not line: - break + for line in sys.stdin: line = line.strip() if not line: # skip empty lines (ie: newlines) diff --git a/data_hacks/run_for.py b/data_hacks/run_for.py index 55c4259..1e6e26b 100644 --- a/data_hacks/run_for.py +++ b/data_hacks/run_for.py @@ -42,10 +42,7 @@ def getruntime(arg): def run(runtime): end = time.time() + runtime - while True: - line = sys.stdin.readline() - if not line: - break + for line in sys.stdin: sys.stdout.write(line) if time.time() > end: return @@ -62,4 +59,4 @@ if __name__ == "__main__": if not runtime: print usage sys.exit(1) - run(runtime)
\ No newline at end of file + run(runtime) diff --git a/data_hacks/sample.py b/data_hacks/sample.py index df3343d..c945de1 100644 --- a/data_hacks/sample.py +++ b/data_hacks/sample.py @@ -27,10 +27,7 @@ from decimal import Decimal def run(sample_rate): input_stream = sys.stdin - while True: - line = input_stream.readline() - if not line: - break + for line in input_stream: if random.randint(1,100) <= sample_rate: sys.stdout.write(line) |