{"action":"opened","issue":{"url":"https://api.github.com/repos/pearselab/python-introduction-marleyhaupt1/issues/2","repository_url":"https://api.github.com/repos/pearselab/python-introduction-marleyhaupt1","labels_url":"https://api.github.com/repos/pearselab/python-introduction-marleyhaupt1/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/pearselab/python-introduction-marleyhaupt1/issues/2/comments","events_url":"https://api.github.com/repos/pearselab/python-introduction-marleyhaupt1/issues/2/events","html_url":"https://github.com/pearselab/python-introduction-marleyhaupt1/issues/2","id":190964457,"number":2,"title":"Classes","user":{"login":"willpearse","id":1236050,"avatar_url":"https://avatars.githubusercontent.com/u/1236050?v=3","gravatar_id":"","url":"https://api.github.com/users/willpearse","html_url":"https://github.com/willpearse","followers_url":"https://api.github.com/users/willpearse/followers","following_url":"https://api.github.com/users/willpearse/following{/other_user}","gists_url":"https://api.github.com/users/willpearse/gists{/gist_id}","starred_url":"https://api.github.com/users/willpearse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willpearse/subscriptions","organizations_url":"https://api.github.com/users/willpearse/orgs","repos_url":"https://api.github.com/users/willpearse/repos","events_url":"https://api.github.com/users/willpearse/events{/privacy}","received_events_url":"https://api.github.com/users/willpearse/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-22T10:43:10Z","updated_at":"2016-11-22T10:43:10Z","closed_at":null,"body":"```{python}\r\nclass Point:\r\n    def __init__(self, x, y):\r\n        self.x, self.y = x, y\r\n\r\n    def distance(other_point):\r\n           return ((self.x - other_point.x) ** 2 #...rest of code\r\n\r\nmy_point = Point(3, 4)\r\nmy_point.distance(Point(5, 7))\r\n```\r\n\r\nLook at the code above. Do you see how I'm (1) calling a _method_ on an object (not a function) and (2) how that means I can use the ```self``` keyword within the class method? This is a useful thing to understand.\r\n\r\nIt would be possible to write a function that calculated the distance between two points by defining a separate method that wasn't within the ```class Point``` block (i.e., wasn't indented, and was like the other functions you have written as answers to the other exercises). Does that make sense?\r\n\r\nFinally, notice how I'm using ```.``` to get a slot from the object, not the ```[]``` operators as you were doing. I think you know this, because you use it in part of your code, but it's good to draw attention to it I think."}}
{"actor":{"display_login":"willpearse"}}