home.social

#pep8 — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #pep8, aggregated by home.social.

  1. 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.

    #Python #PEP8

  2. PEP — это не стиль. это язык, которым ты думаешь о коде

    Я долго думала, что PEP — это про оформление. PEP 8: называй переменные вот так, PEP 257: пиши докстринги вот так. Потом начала использовать их по‑настоящему и выяснилось, что часть из них вообще не про то, как выглядит код!

    habr.com/ru/articles/1006908/

    #pep8 #pep544 #pep698 #pep634 #pep695 #python312 #python3 #python

  3. 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.

    Leia em:
    bolha.blog/riverfount/nomear-p

    Compartilhe boas práticas e vamos conversar sobre código que se explica sozinho. #Python #CleanArchitecture #PEP8 #BoasPráticas #EngenhariaDeSoftware

  4. Код, за который не стыдно: Практика чистописания для начинающих Python-разработчиков

    Каждый из нас хотя бы раз в жизни писал код, который можно описать фразой: «Ну, оно как-то работает, лучше не трогать». Мы наспех добавляем костыль, чтобы успеть к дедлайну, оставляем переменную с именем data2 или пишем функцию на 200 строк, обещая себе вернуться к ней «позже». И знаете что? Это «позже» никогда не наступает.

    habr.com/ru/articles/964004/

    #pep8 #python #python3 #kiss #dry #drypython #yagni

  5. [Перевод] PEP 8 как религия: почему Python сам не соблюдает свои же правила

    Команда Python for Devs подготовила перевод статьи о PEP 8. Мысль проста: споры о стиле в Python часто сводятся к одному — snake_case против camelCase. Даже сам Python не следует своим же правилам. Так стоит ли вообще относиться к PEP 8 как к догме?

    habr.com/ru/articles/953412/

    #Python #PEP8 #стиль_кода #читаемость #snake_case #camelCase #закон_Свейгарта #правила #разработчики #open_source

  6. I’ve already made good progress in refactoring my python code. Thanks to my new love, PEP8 ❤️

    #refactoring #python #PEP8

  7. Использование подчеркивания в коде на Python

    Подчёркивание _ — это символ, который используются в именах в коде на Питоне. Он влияет на то, как код работает и как код читают. Знания о том, куда поместить подчёркивание, помогает писать код.

    habr.com/ru/articles/842954/

    #python #pep8

  8. 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.

    github.com/python/peps/pull/39

    peps.python.org/pep-0007/#code

    #Python #PEP7 #PEP8 #StyleGuide #KnuthStyle

  9. Улучшаем python код в пару кликов

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

    habr.com/ru/articles/836642/

    #python #linters #pep8 #black #vscode

  10. 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

    pythonmorsels.com/checking-for

  11. Основы чистого кода на Python (PEP8, SOLID, ООП) ::: часть 1

    Когда вы уже написали несколько своих небольших пет-проектов, вы начинаете понимать что чистый код, архитектура и другие паттерны программирования начинают иметь смысл. В масштабируемых, командный или коммерческих проектах это несет особую ценность. Изучив эти принципы, новички получат представление о построении надежных, гибких и легко тестируемых приложений, что позволит им сохранить ясность кодовой базы и возможность ее сопровождения по мере роста их проектов. В этой статье мы разберем: что такое PEP8, что такое SOLID и какие есть правила написания чистого кода. А во второй части мы разберем что такое poetry, тесты и методологии разработки.

    habr.com/ru/articles/836678/

    #python #clean_code #clean_architecture #pep8 #SOLID #DRY #KISS #unixway #чистый_код #ООП

  12. 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.

  13. Surprised to see that many examples on peps.python.org/pep-0008/ are not using 2 lines between "top-level" functions..

  14. 🆕 🎨 Inspired by pep8.org, we've added green and red sidebars to the code examples at 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.
    accessguide.io/guide/colorblin

    We can add similar borders to help illustrate other PEPs too.

    #Python #PEP8 #PEPs #PEP

  15. @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.

    #Python #PEP8 #style

  16. @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...

    peps.python.org/pep-0008/#othe

    PEP 8 is for the stdlib, you can ignore for your code.

    #Python #PEP8 #style

  17. @arfs6

    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.

    #PEP8 #linewidth #width #wide #chars #code #black

  18. @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.

  19. A number of the things discussed in the film can also be found in #Python's #PEP8

  20. "🎵 The #PEP 8 Song 🎵" #Python #PEP8
    🎤 youtube.com/watch?v=hgI0p1zf31
    📄 pep8.org/
    « You don't need any curly braces
    just four spaces
    just four spaces

    Wildcard imports should be avoided
    in most cases
    in most cases

    Try to make sure there's no trailing whitespace
    it's confusing
    it's confusing

    Trailing commas go behind list items
    git blame tightens
    git blame tightens

    And comments are important
    as long as they're maintained
    when comments are misleading it will drive people insane
    […] »

  21. 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
  22. "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)
    ieeexplore.ieee.org/document/8
    sci-hub.tw/10.1109/MSR.2019.00

    #PEP8 #StackOverflow

  23. @holger If Black would at least indent by tabs! And yes, I know PEP8 says spaces. But, indenting by spaces is just plain wrong!

    #pep8 #black #tabsVsSpaces