Created
December 30, 2015 15:45
-
-
Save chartjes/b2679917364f0e4ae913 to your computer and use it in GitHub Desktop.
There must be a more idiomatic way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for container in containers: | |
p1 = re.compile('.*?kinto_read-only_(\d)$') | |
p2 = re.compile('.*?kinto_master_(\d)$') | |
print container['Names'] | |
if container['Names']: | |
for name in container['Names']: | |
if p1.match(name): | |
ports = container['Ports'] | |
for port in ports: | |
self.read_only['ip'] = port['IP'] | |
self.read_only['port'] = port['PrivatePort'] | |
if p2.match(name): | |
ports = container['Ports'] | |
for port in ports: | |
self.master['ip'] = port['IP'] | |
self.master['port'] = port['PrivatePort'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nitpick: I would not use list comprehensions to filter out things, because it means you are looping over the whole list at most twice -- which is suboptimal