#pep8 — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #pep8, aggregated by home.social.
-
WHEREAS,
Most developers these days work with a GUI;
Most screens these days use a 16:9 aspect ratio;
Hardly anyone uses a screen resolution of less than 1920px horizontal;
Even at a font size of 14pt, one can fit approximately 180 monospace characters in a terminal of that width;NOW, THEREFORE, BE IT RESOLVED,
PEP 8's current 79-character line length limit be doubled.
-
PEP — это не стиль. это язык, которым ты думаешь о коде
Я долго думала, что PEP — это про оформление. PEP 8: называй переменные вот так, PEP 257: пиши докстринги вот так. Потом начала использовать их по‑настоящему и выяснилось, что часть из них вообще не про то, как выглядит код!
https://habr.com/ru/articles/1006908/
#pep8 #pep544 #pep698 #pep634 #pep695 #python312 #python3 #python
-
Nomear variáveis é um ato de design, não de estética.
No meu novo artigo, mostro como combinar Clean Architecture e PEP 8 para escrever nomes claros, concisos e inteligentes em Python — com exemplos reais e um mini refactor no final.
Compartilhe boas práticas e vamos conversar sobre código que se explica sozinho. #Python #CleanArchitecture #PEP8 #BoasPráticas #EngenhariaDeSoftware
-
-
Код, за который не стыдно: Практика чистописания для начинающих Python-разработчиков
Каждый из нас хотя бы раз в жизни писал код, который можно описать фразой: «Ну, оно как-то работает, лучше не трогать». Мы наспех добавляем костыль, чтобы успеть к дедлайну, оставляем переменную с именем data2 или пишем функцию на 200 строк, обещая себе вернуться к ней «позже». И знаете что? Это «позже» никогда не наступает.
-
[Перевод] PEP 8 как религия: почему Python сам не соблюдает свои же правила
Команда Python for Devs подготовила перевод статьи о PEP 8. Мысль проста: споры о стиле в Python часто сводятся к одному — snake_case против camelCase. Даже сам Python не следует своим же правилам. Так стоит ли вообще относиться к PEP 8 как к догме?
https://habr.com/ru/articles/953412/
#Python #PEP8 #стиль_кода #читаемость #snake_case #camelCase #закон_Свейгарта #правила #разработчики #open_source
-
I’ve already made good progress in refactoring my python code. Thanks to my new love, PEP8 ❤️
-
Использование подчеркивания в коде на Python
Подчёркивание _ — это символ, который используются в именах в коде на Питоне. Он влияет на то, как код работает и как код читают. Знания о том, куда поместить подчёркивание, помогает писать код.
-
Style guide news!
Do you write C code for CPython itself?
PEP 7 (Style Guide for C Code) has been updated to allow putting newlines before operators, "Knuth style":
if (type->tp_dictoffset != 0
&& base->tp_dictoffset == 0
&& type->tp_dictoffset == b_size
&& (size_t)t_size == b_size + sizeof(PyObject *))
{
return 0;
}This is similar to PEP 8 and Black style for Python code.
https://github.com/python/peps/pull/3931/files
-
Улучшаем python код в пару кликов
Разрабатывая огромные проекты в команде сталкиваешься с проблемой, что люди не понимают друг друга, и каждый пишет в своей стилистике. Поэтому в дальнейшем будет трудно поддерживать этот код В статье научимся писать код в единой стилистике и даже делать это автоматически. Улучшать проекты!
-
Checking for an empty list in Python - Python Morsels (@treyhunner)
Various methods to check if a list is empty in Python:
➡️ checking the list's length,
➡️ evaluating the list's truthiness
➡️ comparing the list to another empty list#Python #Truthiness #PEP8 #DuckTyping #Programming #PythonProgramming
https://www.pythonmorsels.com/checking-for-an-empty-list-in-python/
-
Основы чистого кода на Python (PEP8, SOLID, ООП) ::: часть 1
Когда вы уже написали несколько своих небольших пет-проектов, вы начинаете понимать что чистый код, архитектура и другие паттерны программирования начинают иметь смысл. В масштабируемых, командный или коммерческих проектах это несет особую ценность. Изучив эти принципы, новички получат представление о построении надежных, гибких и легко тестируемых приложений, что позволит им сохранить ясность кодовой базы и возможность ее сопровождения по мере роста их проектов. В этой статье мы разберем: что такое PEP8, что такое SOLID и какие есть правила написания чистого кода. А во второй части мы разберем что такое poetry, тесты и методологии разработки.
https://habr.com/ru/articles/836678/
#python #clean_code #clean_architecture #pep8 #SOLID #DRY #KISS #unixway #чистый_код #ООП
-
Sometimes I wish #Python had stricter standards. Example: the max length that regulates #PEP8 is 79, but #Black maintained by the same Python suggests 88 by default.
All these years programming with Python, I've been trying to use standards closer to PEP 8 and it would be nice to have an effortless Python setup, but apparently everyone is lost in this sense. -
🆕 🎨 Inspired by https://pep8.org, we've added green and red sidebars to the code examples at https://peps.python.org/pep-0008/ to help illustrate which are recommended and which are not recommended.
For accessibility, we don't rely on colour alone to convey information; as before, the info about whether examples are recommended is included in the text.
https://www.accessguide.io/guide/colorblindWe can add similar borders to help illustrate other PEPs too.
-
@hugovk @joranelias Yes, I know that's in PEP 8 and in many other style guides that either copied large parts of PEP 8 or independently came to the same conclusion. But what I meant was, I couldn't tell you why that landed in PEP 8 and all those other guides in the first place, other than some vague sense of it looking better.
-
@diazona @joranelias
It's in PEP 8:Always surround these binary operators with a single space on either side, assignment (=)...
Don’t use spaces around the = sign when used to indicate a keyword argument, or when used to indicate a default value for an unannotated function parameter...
When combining an argument annotation with a default value, however, do use spaces around the = sign...
https://peps.python.org/pep-0008/#other-recommendations
PEP 8 is for the stdlib, you can ignore for your code.
-
PEP-8 still says 79 chars IIRC, but at this point that's honoured more in the breach than the observance.
With modern screens and editors, >80 isn't really a problem for most. Black defaults to 88; I happen to like 96. A company I work for has standardized on 120, which IMHO is too wide.
Pick something you like, configure black/your editor/etc to observe it, and be consistent, and you'll be fine.
-
@yantor3d @rickardlindberg I usually do twice the white space that #PEP8 calls for. I do two blank lines between methods because single blank lines may already occur inside functions.
-
"🎵 The #PEP 8 Song 🎵" #Python #PEP8
🎤 https://www.youtube.com/watch?v=hgI0p1zf31k
📄 https://pep8.org/
« You don't need any curly braces
just four spaces
just four spacesWildcard imports should be avoided
in most cases
in most casesTry to make sure there's no trailing whitespace
it's confusing
it's confusingTrailing commas go behind list items
git blame tightens
git blame tightensAnd comments are important
as long as they're maintained
when comments are misleading it will drive people insane
[…] » -
I wanna dog on this, but this is actually a not a bad way to remember the #Python #pep8 style guide.
https://www.youtube.com/watch?v=hgI0p1zf31k -
"Our findings suggest that #Python code snippets on Stack Overflow do not represent good coding #style and may not be suitable for mining or learning tasks. Future work should investigate whether the same can be observed for other languages."
"Python Coding Style Compliance on Stack Overflow" (Nikolaos Bafatakis, Niels Boecker, Wenjie Boon, Martin Cabello Salazar, Jens Krinke, Gazi Oznacar, Robert White)
• https://ieeexplore.ieee.org/document/8816812
• https://sci-hub.tw/10.1109/MSR.2019.00042 -
@holger If Black would at least indent by tabs! And yes, I know PEP8 says spaces. But, indenting by spaces is just plain wrong!