From eb9e279ebdecc8216777dd197978aaeadb8af1f0 Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Sun, 23 Dec 2012 19:13:19 +0800 Subject: [PATCH] examples: python: use .format --- examples/python_example.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/python_example.py b/examples/python_example.py index e8cd89af..4cb8cafd 100644 --- a/examples/python_example.py +++ b/examples/python_example.py @@ -20,7 +20,7 @@ def timing(self, stat, time, sample_rate=1): >>> client.timing('some.time', 500) """ stats = {} - stats[stat] = "%d|ms" % time + stats[stat] = "{0}|ms".format(time) self.send(stats, sample_rate) def increment(self, stats, sample_rate=1): @@ -50,7 +50,7 @@ def update_stats(self, stats, delta=1, sampleRate=1): stats = [stats] data = {} for stat in stats: - data[stat] = "%s|c" % delta + data[stat] = "{0}|c".format(delta) self.send(data, sampleRate) def send(self, data, sample_rate=1): @@ -62,14 +62,14 @@ def send(self, data, sample_rate=1): if (sample_rate < 1): if random() <= sample_rate: for stat, value in data.items(): - sampled_data[stat] = "%s|@%s" %(value, sample_rate) + sampled_data[stat] = "{0}|@{1}".format(value, sample_rate) else: sampled_data = data udp_sock = socket(AF_INET, SOCK_DGRAM) try: for stat, value in sampled_data.items(): - send_data = "%s:%s" % (stat, value) + send_data = "{0}:{1}".format(stat, value) udp_sock.sendto(send_data.encode('utf-8'), self.addr) except Exception: import sys