mindly.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
Mindly.Social is an English speaking, friendly Mastodon instance created for people who want to use their brains and their hearts to make social networking more social. 🧠💖

Administered by:

Server stats:

1.2K
active users

#PEP8

0 posts0 participants0 posts today
WetHat💦<p>Checking for an empty list in Python - Python Morsels (<span class="h-card" translate="no"><a href="https://mastodon.social/@treyhunner" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>treyhunner</span></a></span>)</p><p>Various methods to check if a list is empty in Python:<br>➡️ checking the list's length,<br>➡️ evaluating the list's truthiness<br>➡️ comparing the list to another empty list </p><p><a href="https://fosstodon.org/tags/Python" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Python</span></a> <a href="https://fosstodon.org/tags/Truthiness" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Truthiness</span></a> <a href="https://fosstodon.org/tags/PEP8" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>PEP8</span></a> <a href="https://fosstodon.org/tags/DuckTyping" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>DuckTyping</span></a> <a href="https://fosstodon.org/tags/Programming" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Programming</span></a> <a href="https://fosstodon.org/tags/PythonProgramming" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>PythonProgramming</span></a></p><p><a href="https://www.pythonmorsels.com/checking-for-an-empty-list-in-python/" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://www.</span><span class="ellipsis">pythonmorsels.com/checking-for</span><span class="invisible">-an-empty-list-in-python/</span></a></p>
timvw<p>Surprised to see that many examples on <a href="https://peps.python.org/pep-0008/" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="">peps.python.org/pep-0008/</span><span class="invisible"></span></a> are not using 2 lines between "top-level" functions.. <a href="https://fosstodon.org/tags/python" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>python</span></a> <a href="https://fosstodon.org/tags/pep8" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>pep8</span></a></p>
Hugo van Kemenade<p>🆕 🎨 Inspired by <a href="https://pep8.org" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="">pep8.org</span><span class="invisible"></span></a>, we've added green and red sidebars to the code examples at <a href="https://peps.python.org/pep-0008/" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="">peps.python.org/pep-0008/</span><span class="invisible"></span></a> to help illustrate which are recommended and which are not recommended.</p><p>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.<br><a href="https://www.accessguide.io/guide/colorblind" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://www.</span><span class="ellipsis">accessguide.io/guide/colorblin</span><span class="invisible">d</span></a></p><p>We can add similar borders to help illustrate other PEPs too.</p><p><a href="https://mastodon.social/tags/Python" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Python</span></a> <a href="https://mastodon.social/tags/PEP8" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>PEP8</span></a> <a href="https://mastodon.social/tags/PEPs" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>PEPs</span></a> <a href="https://mastodon.social/tags/PEP" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>PEP</span></a></p>
David Zaslavsky<p><span class="h-card" translate="no"><a href="https://mastodon.social/@hugovk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>hugovk</span></a></span> <span class="h-card" translate="no"><a href="https://mastodon.social/@joranelias" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>joranelias</span></a></span> 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.</p><p><a href="https://techhub.social/tags/Python" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Python</span></a> <a href="https://techhub.social/tags/PEP8" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>PEP8</span></a> <a href="https://techhub.social/tags/style" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>style</span></a></p>
Hugo van Kemenade<p><span class="h-card" translate="no"><a href="https://techhub.social/@diazona" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>diazona</span></a></span> <span class="h-card" translate="no"><a href="https://mastodon.social/@joranelias" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>joranelias</span></a></span><br>It's in PEP 8:</p><p>Always surround these binary operators with a single space on either side, assignment (=)... </p><p>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...</p><p>When combining an argument annotation with a default value, however, do use spaces around the = sign...</p><p><a href="https://peps.python.org/pep-0008/#other-recommendations" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">peps.python.org/pep-0008/#othe</span><span class="invisible">r-recommendations</span></a> </p><p>PEP 8 is for the stdlib, you can ignore for your code.</p><p><a href="https://mastodon.social/tags/Python" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Python</span></a> <a href="https://mastodon.social/tags/PEP8" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>PEP8</span></a> <a href="https://mastodon.social/tags/style" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>style</span></a></p>
C.<p><span class="h-card" translate="no"><a href="https://hachyderm.io/@arfs6" class="u-url mention">@<span>arfs6</span></a></span> </p><p>PEP-8 still says 79 chars IIRC, but at this point that&#39;s honoured more in the breach than the observance.</p><p>With modern screens and editors, &gt;80 isn&#39;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.</p><p>Pick something you like, configure black/your editor/etc to observe it, and be consistent, and you&#39;ll be fine.</p><p><a href="https://mindly.social/tags/PEP8" class="mention hashtag" rel="tag">#<span>PEP8</span></a> <a href="https://mindly.social/tags/linewidth" class="mention hashtag" rel="tag">#<span>linewidth</span></a> <a href="https://mindly.social/tags/width" class="mention hashtag" rel="tag">#<span>width</span></a> <a href="https://mindly.social/tags/wide" class="mention hashtag" rel="tag">#<span>wide</span></a> <a href="https://mindly.social/tags/chars" class="mention hashtag" rel="tag">#<span>chars</span></a> <a href="https://mindly.social/tags/code" class="mention hashtag" rel="tag">#<span>code</span></a> <a href="https://mindly.social/tags/black" class="mention hashtag" rel="tag">#<span>black</span></a></p>