Skip to content

Instantly share code, notes, and snippets.

@sinistersnare
Created November 8, 2013 14:16
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 sinistersnare/7371620 to your computer and use it in GitHub Desktop.
Save sinistersnare/7371620 to your computer and use it in GitHub Desktop.
Showing a CS1 kid classes!
class Point(object):
def __init__(self,x,y):
self.x = x
self.y = y
def set(self,x,y):
self.x = x
self.y = y
def getx(self):
return self.x
def gety(self):
return self.y
def __str__(self):
return "<Point: {},{}>".format(self.x,self.y)
def main():
pos = Point(2,3)
newx, newy = raw_input('new x: '), raw_input('new y: ')
pos.set(newx,newy)
print pos
print str(pos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment