Skip to content

Instantly share code, notes, and snippets.

@tmastny
Created July 6, 2020 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmastny/17f03c7fbd32549c7dc14d2cc3d8a8d2 to your computer and use it in GitHub Desktop.
Save tmastny/17f03c7fbd32549c7dc14d2cc3d8a8d2 to your computer and use it in GitHub Desktop.
# References:
# https://ipython.readthedocs.io/en/stable/config/integrating.html
# https://stackoverflow.com/questions/17974777/tab-complete-dictionary-keys-in-ipython
class Shape2():
area = 1
perimeter = 1
location = 1
def __getitem__(self, key):
return getattr(self, key)
def _ipython_key_completions_(self):
return ["area", "perimeter", "location"]
s = Shape2()
# in ipython/jupyter type
# s["lo<TAB>
# to autocomplete
s["location"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment