Skip to content

Instantly share code, notes, and snippets.

@mistermocha
Created October 25, 2014 23:53
Show Gist options
  • Save mistermocha/b838fa9c4ceaa5488fb7 to your computer and use it in GitHub Desktop.
Save mistermocha/b838fa9c4ceaa5488fb7 to your computer and use it in GitHub Desktop.
domain_counts={}
for url in urls:
# prime the dict if the domain isn't there
if not domain_counts.get(domain):
domain_counts = {}
# split_your_url does not exist
domain, path = split_your_url(url)
# again, prime the child dict if the path isn't there
if not domain_counts[domain].get(path):
domain_counts[domain][path] = 0
domain_counts[domain][path] += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment