Skip to content

Instantly share code, notes, and snippets.

@sloria
Created June 30, 2013 16:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sloria/5895737 to your computer and use it in GitHub Desktop.
Save sloria/5895737 to your computer and use it in GitHub Desktop.
class Point:
def __init__(self, x, y):
self.x, self.y = x, y
# Sometimes need more flexibility --> use properties
class Point:
def __init__(self, x, y):
self._x, self._y = x, y
@property
def x(self):
return self._x
@x.setter
def x(self, value):
self._x = value
@mbrenig
Copy link

mbrenig commented Feb 28, 2014

Might be worth noting that you need to declare:

class Point(object):

unless you're running Python 3.0+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment