-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyfunctions.py
More file actions
24 lines (15 loc) · 930 Bytes
/
myfunctions.py
File metadata and controls
24 lines (15 loc) · 930 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
FILEPATH = '../files/todos.txt' # the constants used at multiple places
def get_todos(filepath=FILEPATH): # default value (if there's a non default value then that should be called before default values)
""" Read a text file and return the list of todo items """ # this is doc-string | help(get_todos) will show this
with open(filepath, 'r') as file_local:
todos_local = file_local.readlines()
return todos_local # this todos_local is local to the function and cannot be called outside this function.
def write_todos(todos_arg, filepath=FILEPATH): # non-default values to be called before default values
""" Write the todo list items to a file """
with open(filepath, 'w') as file_local:
file_local.writelines(todos_arg)
return None
help(get_todos)
help(write_todos)
if __name__ == "__main__":
print("you ran the myfunctions script directly")