Skip to content

Commit

Permalink
examples: python: use .format
Browse files Browse the repository at this point in the history
  • Loading branch information
SaveTheRbtz committed Dec 23, 2012
1 parent d67b1c0 commit eb9e279
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/python_example.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit eb9e279

Please sign in to comment.