Skip to content

Instantly share code, notes, and snippets.

@jasonrahm
Created January 21, 2020 21:07
Show Gist options
  • Save jasonrahm/c89b45d889304604782c2674cba2307c to your computer and use it in GitHub Desktop.
Save jasonrahm/c89b45d889304604782c2674cba2307c to your computer and use it in GitHub Desktop.
Python/PyGithub caching?
# Get the repo
>>> repo = gh.get_repo('f5devcentral/f5go')
# Get the repo commits
>>> commits = repo.get_commits()
# Print the last commit, but this fails as out of range
>>> print(commits[-1].committer.last_modified, commits[-1].committer.name)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/rahm/PycharmProjects/f5dc_github/py37/lib/python3.7/site-packages/github/PaginatedList.py", line 53, in __getitem__
return self.__elements[index]
IndexError: list index out of range
# Loop through the commits, printing but changing nothing and this succeeds
>>> for commit in commits:
... print(commit.committer.last_modified, commit.committer.name)
...
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT GitHub Web Flow
Tue, 28 May 2019 17:49:53 GMT Bryan
Tue, 28 May 2019 17:49:53 GMT GitHub Web Flow
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT GitHub Web Flow
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT GitHub Web Flow
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Tue, 28 May 2019 17:49:53 GMT GitHub Web Flow
Tue, 28 May 2019 17:49:53 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT GitHub Web Flow
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT GitHub Web Flow
Fri, 23 Sep 2016 21:36:49 GMT GitHub Web Flow
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT GitHub Web Flow
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT GitHub Web Flow
Fri, 23 Sep 2016 21:36:49 GMT GitHub Web Flow
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Sean Smith
Fri, 23 Sep 2016 21:36:49 GMT Bill Booth
Fri, 23 Sep 2016 21:36:49 GMT Bill Booth
Fri, 23 Sep 2016 21:36:49 GMT Bill Booth
# Try to print again, and now it succeeds?!?
>>> print(commits[-1].committer.last_modified, commits[-1].committer.name)
Thu, 09 Jan 2020 19:03:45 GMT Bill Booth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment