Last active
June 3, 2020 21:25
-
-
Save minusworld/27ea761d14af4f3e29216bbed3c6707f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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