Skip to content

Instantly share code, notes, and snippets.

@seedifferently
Created June 14, 2017 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 seedifferently/c11541b734f29ee22d150eb735206c42 to your computer and use it in GitHub Desktop.
Save seedifferently/c11541b734f29ee22d150eb735206c42 to your computer and use it in GitHub Desktop.
Python ip counter dict example
# assuming "ip_counts" is our dict and "req.ip_address" is the requestor's IP address
if req.ip_address in ip_counts:
# increment the count
ip_counts[req.ip_address] += 1
else:
# set an initial count
ip_counts[req.ip_address] = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment