Created
March 15, 2018 22:50
-
-
Save bandit145/195f36f160678c9eadd1c5763c78cb56 to your computer and use it in GitHub Desktop.
Using a staticmethod to return instantiated versions of itself
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 System: | |
names_from_api = ['server1','server2','server3'] | |
def __init__(self, hostname): | |
self.hostname = hostname | |
@staticmethod | |
def get_systems(name): | |
system_list = [] | |
for hostname in System.names_from_api: | |
if name == hostname: | |
system_list.append(System(hostname)) | |
return system_list |
jffz
commented
Mar 15, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment