Skip to content

HW2 with tests (all ok)#16

Open
YAKOVLENKO wants to merge 1 commit into
kib-courses:masterfrom
YAKOVLENKO:HW2_Yakovlenko
Open

HW2 with tests (all ok)#16
YAKOVLENKO wants to merge 1 commit into
kib-courses:masterfrom
YAKOVLENKO:HW2_Yakovlenko

Conversation

@YAKOVLENKO
Copy link
Copy Markdown

Все тесты пройдены.

Copy link
Copy Markdown
Collaborator

@romvano romvano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Логика реализовано достаточно грамотно, главное замечание - к двойным подчеркиваниям

Comment thread homework/patient.py

class LogDescriptor:
def __init__(self, file_path, log_name, log_level):
self.__log = logging.getLogger(log_name)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

двойное нижнее подчеркивание нужно только при реализации сложной логики наследования. Для того, чтобы показать другим программистам, что не нужно трогать это поле извне, лучше использовать одинарное подчеркивание

Comment thread homework/patient.py
class Patient:
def __init__(self, *args, **kwargs):
pass
__document_types = {'паспорт': 10,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тоже стоит изменить двойные подчеркивания на одинарные

Comment thread homework/patient.py
from calendar import monthrange


class LogDescriptor:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

но это же не дескриптор)

Comment thread homework/patient.py

def __init__(self, first_name, last_name, birth_date, phone, document_type, document_id):
self.__first_name = self._get_correct_name(first_name)
self.__last_name = self._get_correct_name(last_name)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и эти все

Comment thread homework/patient.py
f"Тип документа: {self.__document_type}\n"
f"Номер документа: {self.__document_id}\n")

def __getattr__(self, item):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а это зачем?

Comment thread homework/patient.py
raise ValueError('Wrong number of digits in document id')
return document_id

@classmethod
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classmethod нужен, если есть сложная логика наследования или используются атрибуты класса. В этом случае стоит обойтись статическим методом

Comment thread homework/patient.py

class PatientCollectionIterator:
def __init__(self, path_to_file, limit=None):
self.__path_to_file = path_to_file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

то же замечание к подчеркиваниям

Comment thread homework/patient.py
if self.__limit is None:
end = file_len
else:
if self.__limit > len(pd.read_csv(self.__path_to_file, header=None)):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

дважды приходится считывать весь файл

Comment thread homework/patient.py
end = self.__limit
if self.__index < end:
self.__index += 1
patient_info = pd.read_csv(self.__path_to_file, nrows=self.__index, dtype=str,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

даже не дважды, а на каждой итерации в оперативу загоняется целиковый файл. А если он большой?

Comment thread homework/patient.py

def __init__(self, path_to_file):
if not os.path.isfile(path_to_file):
raise FileNotFoundError(f'Not exist: {path_to_file}')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а логировать?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants