Skip to content

Instantly share code, notes, and snippets.

@ustropo
Last active February 4, 2023 10:00
Show Gist options
  • Save ustropo/c71b2ee50617a4e534819208f07bb129 to your computer and use it in GitHub Desktop.
Save ustropo/c71b2ee50617a4e534819208f07bb129 to your computer and use it in GitHub Desktop.
def bark(self):
print("Wooof! " + self.name)
def walk(self):
print("Hey! I'm walking!")
def init(self, name):
self.name = name
Dog = type("Dog", (object,), {"bark": bark, "walk": walk, "init": init})
d = Dog()
d.init("name")
d.bark()
d.walk()
## >> Output:
# Wooof! rex
# Hey! I'm walking!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment