class MetaData():
maxSize = 2**10
# class definition code
if not os.path.exists('sample.data'):
SSD = open('sample.data', 'wb+')
data = {
0: [],
1: {'.': None,}
}
data[1]['~'] = data[1]
MetaData.save() # i want to call the save function here
# class function
@classmethod
def save(cls):
cls.SSD.seek(0)
cls.SSD.write(b' ' * cls.maxSize)
cls.SSD.seek(0)
cls.SSD.write(pickle.dumps(cls.data))
I want to use the save()
function inside the class block. I've tried MetaDate.save()
and simply save()
both of which throw errors
Is there any way to achieve this?
Edit
Yes, maxSize
is a class var and yes i can access it using cls.maxSize
.
SSD
isn't a member, socls.SSD
won't work. – Fetlockself
has been renamed – Cornfield