Skip to content

Instantly share code, notes, and snippets.

@otobrglez
Created November 10, 2016 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save otobrglez/3dccc15328c447b8962a527a22076b79 to your computer and use it in GitHub Desktop.
Save otobrglez/3dccc15328c447b8962a527a22076b79 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from pprint import pprint
servers = {
"0.0.1.1": {
"status": "OK"
},
"0.0.1.2": {
"status": "ERROR"
},
"0.2.2.2": {
"status": "OK"
}
}
print("All servers")
pprint(servers)
print("OK servers")
ok_servers = { k:v for k,v in servers.items() if v["status"] is "OK" }
pprint(ok_servers)
print("Servers with ERROR")
error_servers = { k:v for k,v in servers.items() if v["status"] is not "OK" }
pprint(error_servers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment