A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
import datetime | |
from google.appengine.ext import ndb | |
# eventually import custom User class here and adjust paths below | |
# parameter in timedelta() assumes that tokens expire ~3 months after creation: | |
expiredTokens = User.token_model.query(User.token_model.created <= (datetime.datetime.utcnow() - datetime.timedelta(3*365/12))) | |
# delete the tokens in bulks of 100: | |
while expiredTokens.count() > 0: | |
keys = expiredTokens.fetch(100, keys_only=True) |
I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\