Skip to content
Browse files

Use List Comprehension to create message list

this is faster and more pythonic than adding to an existing list
  • Loading branch information...
1 parent 5327935 commit d409767177249b7178692425fda709406b2f437c @odeits odeits committed May 3, 2012
Showing with 1 addition and 6 deletions.
  1. +1 −6 iron_mq.py
View
7 iron_mq.py
@@ -243,12 +243,7 @@ def postMessage(self, queue_name, messages=[], project_id=None):
project_id = self.project_id
url = "%sprojects/%s/queues/%s/messages?oauth=%s" % (self.url,
project_id, queue_name, self.token)
- msgs = []
- for message in messages:
- if isinstance(message, basestring):
- msgs.append({"body": message})
- else:
- msgs.append(message)
+ msgs = [ {'body':message} if isinstance(message,basestring) else message for message in messages]
data = json.dumps({"messages": msgs})
dataLen = len(data)

0 comments on commit d409767

Please sign in to comment.
Something went wrong with that request. Please try again.