FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
code-guild/code-guild/python/files/save.py at master · grantholly/code-guild · GitHub
grantholly
code-guild
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
code-guild
/
code-guild
/
python
/
files
/
save.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (23 loc) · 717 Bytes
Breadcrumbs
code-guild
/
code-guild
/
python
/
files
/
save.py
Copy path
File metadata and controls
32 lines (23 loc) · 717 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
json
class
Todo
(
object
):
def
__init__
(
self
):
self
.
templist
=
[]
def
_set
(
self
,
*
tasks
):
for
task
in
tasks
:
self
.
templist
.
append
(
task
)
persistence
=
Storage
()
return
persistence
.
save
(
self
.
templist
)
def
_get
(
self
):
persistence
=
Storage
()
return
persistence
.
load
()
class
Storage
(
object
):
def
save
(
self
,
list_of_tasks
):
with
open
(
"/home/student/data.json"
,
"w"
)
as
out_file
:
json
.
dump
(
list_of_tasks
,
out_file
)
def
load
(
self
):
with
open
(
"/home/student/data.json"
,
"r"
)
as
in_file
:
todo
=
json
.
load
(
in_file
)
print
(
todo
)
my_task
=
Todo
()
my_task
.
_set
(
1
,
2
,
3
,
4
)
my_task
.
_get
()
Back
|
FazBrowse Home
|
New Git URL