Skip to content

Instantly share code, notes, and snippets.

@MrfksIv
Last active September 24, 2018 11:31
Show Gist options
  • Save MrfksIv/171fef828e853f8239ff049dc7af9601 to your computer and use it in GitHub Desktop.
Save MrfksIv/171fef828e853f8239ff049dc7af9601 to your computer and use it in GitHub Desktop.
python_design_patterns introduction code
# This is the class definition
class House(object):
def __init__(self, address, longitude, latitude): # This is the constructor
self.address = address
self.longitude = longitude
self.latitude = latitude
def get_house_position(self):
return "<House @ (%, %)>".format(self.longitude, self.latitude)
# We can now instantiate a House object:
house1 = House('123 Mar Avenue', 43.245, 42.45346) # house1 is now an object of type House. This
# line implicitly calls the __init__ method of House.
print("Type of Object", type(house1), "Memory Address:", id(house1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment