Различия между версиями 1 и 2
Версия 1 от 2020-03-24 16:24:12
Размер: 2839
Редактор: FrBrGeorge
Комментарий:
Версия 2 от 2020-03-24 17:21:48
Размер: 3966
Редактор: FrBrGeorge
Комментарий:
Удаления помечены так. Добавления помечены так.
Строка 4: Строка 4:
Основная ссылка: [[pep:pep-0008]] — рекомендации к ''оформлению'' кода.
 * '''TODO'''
[[pep:pep-0008]] — рекомендации к ''оформлению'' кода.
 * Хороший, годный перевод: https://pep8.ru/doc/pep8/
 * Жёсткость [[pep:pep-0008]]
Строка 8: Строка 9:
 * Основанные на [[pep:pep-0008]]: [[pypi:pep8]], [[pypi:pylint]]  * Основанные на [[pep:pep-0008]]: [[https://pycodestyle.readthedocs.io/en/latest/|pycodestyle]]
Строка 11: Строка 12:
 * Жёсткость [[pep:pep-0008]]
  * [[https://twitter.com/gvanrossum/status/737438918799282178|Pep8 is dead, long live pycodestyle!]], [[https://pycodestyle.readthedocs.io/en/latest/|pycodestyle]]
 * [[https://www.pylint.org|pylint]]
 * Почему так делать не всегда надо :)
 * Ещё один: [[https://www.pylint.org|pylint]]
 * Вообще статическая типизация: [[http://www.mypy-lang.org|MyPy]]

“''A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines. With consistency a great soul has simply nothing to do. He may as well concern himself with his shadow on the wall. Speak what you think now in hard words, and to-morrow speak what to-morrow thinks in hard words again, though it contradict every thing you said to-day. — 'Ah, so you shall be sure to be misunderstood.' — Is it so bad, then, to be misunderstood? Pythagoras was misunderstood, and Socrates, and Jesus, and Luther, and Copernicus, and Galileo, and Newton, and every pure and wise spirit that ever took flesh. To be great is to be misunderstood.''”

Из личных наблюдений:
 * Неряшливость
  * Программирование копипастой (^C^V-style)
  * Лапша (spaghetti code)
  * Шланг (overfunctional code)
  * Не читатель (python underusage)
  * Магические числа
 * Ошибки проектирования
  * Программирование в столбик
  * Переупрощение (пасказлизация)
  * Переусложнение (лиспизация и т. п.)
Строка 23: Строка 37:
Магические числа

Стиль программирования, комментарии и документирование

Оформление кода

pep-0008 — рекомендации к оформлению кода.

Анализаторы кода:

A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines. With consistency a great soul has simply nothing to do. He may as well concern himself with his shadow on the wall. Speak what you think now in hard words, and to-morrow speak what to-morrow thinks in hard words again, though it contradict every thing you said to-day. — 'Ah, so you shall be sure to be misunderstood.' — Is it so bad, then, to be misunderstood? Pythagoras was misunderstood, and Socrates, and Jesus, and Luther, and Copernicus, and Galileo, and Newton, and every pure and wise spirit that ever took flesh. To be great is to be misunderstood.

Из личных наблюдений:

  • Неряшливость
    • Программирование копипастой (CV-style)

    • Лапша (spaghetti code)
    • Шланг (overfunctional code)
    • Не читатель (python underusage)
    • Магические числа
  • Ошибки проектирования
    • Программирование в столбик
    • Переупрощение (пасказлизация)
    • Переусложнение (лиспизация и т. п.)

Комментарии

  • Не «что» и «как», а «зачем» и «почему»
  • Комментарии vs. код на Python (это не Си же)
  • Комментарии vs. строки документации
  • Выковыривание комментариев с помощью inspect.getcomments()

Аннотирование

controlflow.html

https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep526

Документирование

Битва PEP-ов: pep-0256, pep-0258 — оба отвергнуты.

https://wiki.python.org/moin/DocumentationTools#Automatic_Python_API_documentation_generation_tools

Д/З

  • Переработать имеющийся код проекта в соответствие с flake8

    • создать настроечный файл, в котором изменить умолчания, если они не соответствуют дисциплине разработки

LecturesCMC/PythonDevelopment2020/06_Style (последним исправлял пользователь FrBrGeorge 2021-03-31 19:27:12)