Skip to content

Instantly share code, notes, and snippets.

@brydavis
Created June 4, 2019 18:27
Show Gist options
  • Save brydavis/b3a8ef4a31b78b1286acc6169f88d3f1 to your computer and use it in GitHub Desktop.
Save brydavis/b3a8ef4a31b78b1286acc6169f88d3f1 to your computer and use it in GitHub Desktop.
class A:
def __init__(self, x):
self._x = x
@property
def y(self):
return self.x * 2
@y.setter
def y(self, val):
self.x = val / 2
a = A(10)
a.y = 30
a.y * 20
class B:
def __init__(self, x):
self._x = x
self._y = x * 2
def x(self, val=None):
if val:
self._x = val
self._y = val * 2
return self._x
def y(self, val=None):
if val:
self._y = val
self._x = val / 2
return self._y
b = B(10)
b.y(30)
b.y() * 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment