-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
45 lines (38 loc) · 1.18 KB
/
settings.py
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
34
35
36
37
38
39
40
41
42
43
44
45
"""
Usage:
Should be init() at the top of the main file, then add("name", data)
and get("name") in other files when needed
"""
def init():
"""
It creates a global variable called settings and sets it to an empty dictionary.
"""
global settings
settings = {}
def add(name, data):
"""
It takes a name and data as arguments, adds the name and data to the global settings dictionary, and
returns the data
:param name: The name of the setting
:param data: The data to be stored in the settings
:return: The data that was added to the settings dictionary.
"""
global settings
settings[name] = data
return settings[name]
def remove(name):
"""
It deletes the key-value pair from the settings dictionary whose key is the value of the name
parameter
:param name: The name of the setting to remove
"""
global settings
del settings[name]
def get(name):
"""
It returns the value of the key in the settings dictionary that matches the name parameter
:param name: The name of the setting to get
:return: The value of the key 'name' in the dictionary 'settings'
"""
global settings
return settings[name]