Молоденова Александра#13
Conversation
romvano
left a comment
There was a problem hiding this comment.
не реализован правильный Patient.create, из-за этого кривая логика в PatientCollection. Плюс обратить внимание на работу с файлами в PatientCollection. В остальном архитектура решения норм
|
|
||
| def dateIsReal(date): | ||
| year = int(date[:4]) | ||
| if year < 1900 or year > 2020: |
There was a problem hiding this comment.
это всё проще сделать с помощью модуля datetime
| name = sub(pattern, "", name_) | ||
| if len(name)==0: | ||
| return False | ||
| return name |
There was a problem hiding this comment.
логика объект/булево значение редко используется. Лучше либо True/False, либо объект/None
| return False | ||
|
|
||
| if month == 2 and day == 29: | ||
| print("WOW!") |
There was a problem hiding this comment.
лучше всё-таки не велосипедить, потому что при такой логике 29 февраля может быть и в невисокосном годе
| # print(dateIsReal("1978-01-05")) | ||
|
|
||
| def phoneIsValid( phone_): | ||
| pattern = "[^+,0,1,2,3,4,5,6,7,8,9]" |
| instance.paterr.error('Invalid name.') | ||
| instance.paterr.error("Error. User was not created.") | ||
| raise TypeError("not str") | ||
| elif instance.created: |
There was a problem hiding this comment.
не думаю, что атрибут created должен быть обозначен как public
| counter = 0 | ||
| fileBytePos = 0 | ||
| while True: | ||
| inFile = open(self.filepath) |
|
|
||
|
|
||
| class PatientCollection: | ||
| pat = Patient() |
There was a problem hiding this comment.
конкретного пациента не нужно хранить в коллекции
| return | ||
| counter = 0 | ||
| fileBytePos = 0 | ||
| while True: |
There was a problem hiding this comment.
while True - очень неочевидно. Стоит использовать for с учетом количества объектов
| inFile.close() | ||
| return | ||
| self.pat.create(*data.split(' ')) | ||
| yield self.pat |
There was a problem hiding this comment.
исполнение функции приостанавливается, а файловый дескриптор в этот момент остается открытым
| @@ -1,17 +1,117 @@ | |||
| import csv | |||
There was a problem hiding this comment.
ну тут код повторяется, надо бы убрать ненужный файл
There was a problem hiding this comment.
те два файла, а этот оставить =) правда, я уже комментарии там написал
delete needless files, datetime, created->def
No description provided.