Skip to content

Instantly share code, notes, and snippets.

@MarkMichon1
Created November 11, 2019 02:19
Show Gist options
  • Save MarkMichon1/c7dd1ff26cbf1fb39423a1455c4b8713 to your computer and use it in GitHub Desktop.
Save MarkMichon1/c7dd1ff26cbf1fb39423a1455c4b8713 to your computer and use it in GitHub Desktop.
simple class demonstration
class Dog:
def __init__(self):
print('\nThis code is running because I am being initialized!')
self.something_else()
def something_else(self):
print('...And this is something else inside of the __init__!')
def then_this(self, some_input):
print('This is not in the init, but can still be called from using .then_this()')
print(f'And finally: {some_input}')
dog = Dog()
# Then this
dog.then_this('I want you to say this now!')
# This does nothing (yet!) because we didn't call it.
dog_object = Dog
# Uncomment this and see what happens!
# dog2 = dog_object()
# dog2.then_this('This is the second dog!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment