-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Expand file tree
/
Copy pathconfig_v2.py
More file actions
33 lines (27 loc) · 798 Bytes
/
config_v2.py
File metadata and controls
33 lines (27 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Config:
def __init__(self, name):
self.name = name
def set_option(self, key, value):
self.__dict__[key] = value
def get_option(self, key):
return self.__dict__.get(key, None)
def remove_option(self, key):
if key in self.__dict__:
del self.__dict__[key]
# self.__dict__.pop(key)
print(f"'{key}' removed!")
else:
print(f"'{key}' does not exist.")
def clear(self):
self.__dict__.clear()
print("All options removed!")
conf = Config("GUI App")
conf.set_option("theme", "dark")
conf.set_option("size", "200x400")
print(conf.__dict__)
conf.remove_option("size")
print(conf.__dict__)
conf.remove_option("autosave")
print(conf.__dict__)
conf.clear()
print(conf.__dict__)