Skip to content

Instantly share code, notes, and snippets.

@minusworld
Last active June 3, 2020 21:25
Show Gist options
  • Save minusworld/27ea761d14af4f3e29216bbed3c6707f to your computer and use it in GitHub Desktop.
Save minusworld/27ea761d14af4f3e29216bbed3c6707f to your computer and use it in GitHub Desktop.
from typing import Any
class ArchList(list):
"""
A list with a .get method that works like dict.get.
It's also very ancient and has dark magical powers.
To defeat it you must locate and destroy its phylactery.
:3
"""
def get(self, index: int, default=None) -> Any:
try:
return super(ArchList, self).__getitem__(index)
except IndexError:
return default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment