Created
November 11, 2019 02:19
-
-
Save MarkMichon1/c7dd1ff26cbf1fb39423a1455c4b8713 to your computer and use it in GitHub Desktop.
simple class demonstration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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