Skip to content

Instantly share code, notes, and snippets.

@hugovk
Created June 14, 2024 06:43
Show Gist options
  • Save hugovk/264ea7e2ae653bc5abf57bfe171eec55 to your computer and use it in GitHub Desktop.
Save hugovk/264ea7e2ae653bc5abf57bfe171eec55 to your computer and use it in GitHub Desktop.
"""
Find the first PEP created after the last PEP created in the 3xxx range.
"""
import datetime as dt
import json
import urllib.request
with urllib.request.urlopen("https://peps.python.org/peps.json") as url:
peps = json.loads(url.read().decode())
for pep in peps.values():
pep["number"] = int(pep["number"])
pep["created_dt"] = dt.datetime.strptime(pep["created"], "%d-%b-%Y")
peps = sorted(peps.values(), key=lambda x: x["created_dt"])
last_3k = next(pep for pep in reversed(peps) if 3000 <= pep["number"] <= 3999)
next_pep = next(pep for pep in peps if pep["created_dt"] > last_3k["created_dt"])
print(f"Last PEP: {last_3k['number']}, {last_3k['created']}")
print(f"Next PEP: {next_pep['number']}, {next_pep['created']}")
# Last PEP: 3156, 12-Dec-2012
# Next PEP: 432, 28-Dec-2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment