Skip to content

Instantly share code, notes, and snippets.

@Hamatti
Created August 15, 2014 20:04
Show Gist options
  • Select an option

  • Save Hamatti/3391fc4bd3565b3143b7 to your computer and use it in GitHub Desktop.

Select an option

Save Hamatti/3391fc4bd3565b3143b7 to your computer and use it in GitHub Desktop.
class A(object):
def __init__(self, key, value):
self.key = key
self.value = value
@property
def double_value(self):
return self.value * 2
alpha = A('hello', 2)
print alpha.key # prints 'hello'
print alpha.value # prints 2
print alpha.double_value # prints 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment