Skip to content

Instantly share code, notes, and snippets.

@nirum
Last active October 28, 2015 04:54
Show Gist options
  • Save nirum/32cc4866fa5311d04c64 to your computer and use it in GitHub Desktop.
Save nirum/32cc4866fa5311d04c64 to your computer and use it in GitHub Desktop.
classes in python
class Foo(object):
def __init__(self, data):
self.data = data
self.shape = self.data.shape
def __getitem__(self, index):
return self.data[index] ** 2
def __dir__(self):
return ['data']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment