-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.py
32 lines (26 loc) · 878 Bytes
/
functions.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
FILEPATH = "todos.txt"
def files_handle(m, v, f=FILEPATH):
""" Read a text file and return the list of todos items
or Write the to-do items in the text file
following is structure of arguments:
f is file path default file is 'files/todos.txt'
m is "r" read or "w" write
v is variable
"""
if m == "r":
with open(f, m) as file_to_read:
todos_local = file_to_read.readlines()
return todos_local
else:
with open(f, m) as file_to_write:
file_to_write.writelines(v)
def parse(cal):
parts = cal.split(" ")
feet = float(parts[0])
inch = float(parts[1])
meters = feet * 0.3048 + inch * 0.0254
return {"feet": feet, "inch": inch, "meters": meters}
if __name__ != "functions":
print("Hello")
print(files_handle("r", '', f="todos.txt"))
print(parse("3.05559 2.6669"))