Created
August 23, 2022 07:44
-
-
Save lafftar/add78678e559d3642ac14645dd9e3249 to your computer and use it in GitHub Desktop.
This file is to illustrate that child classes have a different base class object than their parent.
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
""" | |
This test is to illustrate that child classes have a different base class object as their parent. | |
""" | |
class Monitor: | |
reqs_sent = 0 | |
class SiteMonitor(Monitor): | |
pass | |
class DiscordMonitor(Monitor): | |
pass | |
if __name__ == "__main__": | |
for _ in range(3): | |
Monitor.reqs_sent += 1 | |
# SiteMonitor.reqs_sent += 1 | |
# DiscordMonitor.reqs_sent += 1 | |
print('Monitor, SiteMonitor, DiscordMonitor') | |
print(Monitor().reqs_sent, SiteMonitor().reqs_sent, DiscordMonitor().reqs_sent, '[Inst. Objects of Class]') | |
print(Monitor.reqs_sent, SiteMonitor.reqs_sent, DiscordMonitor.reqs_sent, '[Non-Inst. Objects of Class]') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment