Lecture13-ClassImplementation-Part1-3pp

Python has a builtin funcdon called isinstanceobject

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: tor
 bob = Person("Bob", "Edmonton")
 
 # bob is an instance of the Person class and so 
 # we can call Person methods on it! print(bob.get_name())! print(bob.get_fave_food())! print(bob.get_city())! bob.move("Toronto")! print(bob.get_city())! 13 What is the output? bob = Person("Bob", "Edmonton")
 print(bob.get_name())! print(bob.get_fave_food())! print(bob.get_city())! bob.move("Toronto")! print(bob.get_city())! 14 Exercises • Add a method to the Person class that updates the favourite food • Add a method called is_neighbour to the Person class that has one parameter (in addiDon to self) and returns True if that Person lives in the same city and False otherwise • Update is_neighbour to return False if the parameter is not an instance of the Person class (see next slide…) 15 5 13 ­11 ­13 isinstance? Python has a built ­in funcDon called isinstance(object, class) which returns...
View Full Document

This document was uploaded on 03/02/2014.

Ask a homework question - tutors are online