Answer the question
In order to leave comments, you need to log in
Why is the array not visible in the method?
I created a class, defined the postsMas array in it and created the save() method below. Further in this method, I wanted to refer to the array, but for some reason unknown to me, the postsMas array is not visible in the save() method. Although I define an array above the method. Please explain why?
Here is the code:
class Post():
title = '1'
pubDate = '2'
time = '3'
postsMas = [
[title, pubDate, time]
]
SAVES_FILE = 'saves.dat'
def save(self):
SAVES_FILE = 'saves.dat'
with open(SAVES_FILE, 'ab') as file:
pickle.dump(postsMas, file)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question