I'm writing simpe OOP programm in Python. The task is to write object's attributes in txt file. I've tried numerous methods but every time I get AttributeError: 'Message' object has no attribute 'self'
. I've been changing file.write(ms1.self.__id)
numerous time but no one helped.
class Message:
def __init__(self, id=10000000, subject='Title', text='Sample Text ', created_at='11.11.11', seen_at='11.11.11', support_group='sample text'):
self.__id = id
self.__subject = subject
self.__text = text
self.__created_at = created_at
self.__seen_at = seen_at
self.__support_group = support_group
ms1 = Message(5775575, 'Order Telephone', 'The order is: Iphone 12 Pro Max 512 gb ', 'Created at:
30.03.20', 'Seen at: 01.04.20', 'Account: Kim2030 \n Tech: Eldorado \n Billing: 5169147129584558 \n
Order: 28048')
file = open('testfile.txt', 'w')
file.write(ms1.self.__id)
file.write(ms1.self.__subject)
file.write(ms1.self.__text)
file.write(ms1.self.__created_at)
file.write(ms1.self.__seen_at)
file.write(ms1.self.__support_group)
file.close()