Skip to content

Instantly share code, notes, and snippets.

@Drvanon
Last active July 22, 2022 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drvanon/83be273a95be0d0beda33f99546a27b9 to your computer and use it in GitHub Desktop.
Save Drvanon/83be273a95be0d0beda33f99546a27b9 to your computer and use it in GitHub Desktop.
class ClassBuilder:
def __init__(self):
self.data = {}
def load_source1(self, params_for_source1):
self.data.update(api_call_source1(params_for_source1))
def load_source1(self, params_for_source2):
self.data.update(api_call_source1(params_for_source2))
def load_from_file(self, file_name):
self.data.update(extract_data_from_file(file_name))
def create():
return MyClass(data=data)
# Should make this immutable somehow.
class MyClass:
data: dict
from dataclasses import dataclass
@dataclass
class MyClass:
name: str
data: str
def load_from_source1(self, params_for_source1):
self.data.update(api_call_source1(params_for_source1))
def load_from_source2(self, params_for_source2):
self.data.update(api_call_source1(params_for_source2))
def load_from_file(self, file_name):
self.data.update(extract_data_from_file(file_name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment