Форум сайта python.su
У меня есть модуль:
# -*- coding:utf-8 -*- #thatModule.py import pickle import time VERSION_NOTES = [] class versionNote(object): def __init__(self, versionNumber, versionNote): self.versionNumber = versionNumber self.versionNote = versionNote self.date = time.asctime() return None def showNote(self): return self.versionNote def dumpVersions(versions): dumpFile = open('versionsDump.pickle', 'wb') versionDump = pickle.dump(versions, dumpFile) dumpFile.close() return None def undumpVersions(): dumpFile = open('versionsDump.pickle', 'rb') versionDump = pickle.load(dumpFile) dumpFile.close() return versionDump def showNote(versionNumber = '0', versionIndex = -1, versions = VERSION_NOTES): versions = undumpVersions() if versionNumber != '0': for version in VERSION_NOTES: if version.versionNumber == versionNumber: versionIndex = VERSION_NOTES.index(version) if versionIndex == -1: return 'VersionNumber was not found' try: return VERSION_NOTES[versionIndex].showNote() except IndexError: return 'VersionIndex was not found' if __name__ == '__main__': VERSION_NOTES = undumpVersions() print(showNote())
#main.py import thatModule def mainAction(): versionNote = updates.showNote() print(versionNote) mainAction()
Traceback (most recent call last): File "main.py", line 139, in <module> mainAction() File "main.py", line 86, in mainAction versionNote = thatModule.showNote() File "C:\Users\BearPro\Documents\Visual Studio 2015\Projects\project\thatModule.py", line 28, in showNote versions = undumpVersions() File "C:\Users\BearPro\Documents\Visual Studio 2015\Projects\project\thatModule.py", line 23, in undumpVersions versionDump = pickle.load(dumpFile) AttributeError: Cant get attribute 'versionNote' on <module '__main__' from main.py'>
Отредактировано BearPro (Дек. 28, 2016 13:38:34)
Офлайн