Skip to content

Instantly share code, notes, and snippets.

@dfbarrero
Last active March 13, 2020 09:57
Show Gist options
  • Select an option

  • Save dfbarrero/9b30c749986885373c8c250b3901ec9d to your computer and use it in GitHub Desktop.

Select an option

Save dfbarrero/9b30c749986885373c8c250b3901ec9d to your computer and use it in GitHub Desktop.
Python OOP naive example.
class Dog:
def __init__(self):
self.name = "Unknown"
self.age = 10
def bit(self):
print(self.name + " has bitten")
def describe(self):
print("Name: ", self.name)
print("Age: ", self.age)
if __name__ == '__main__':
snoopy = Dog()
laika = Dog()
snoopy.name = "Snoopy"
snoopy.age = 4
laika.name = "Laika"
snoopy.bit()
snoopy.describe()
print()
laika.describe()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment