Thursday, January 27, 2022

Python Bytes: #268 Wait, you can Google that?

<p><strong>Watch the live stream:</strong></p> <a href='https://www.youtube.com/watch?v=CWzPMqp5UeA' style='font-weight: bold;'>Watch on YouTube</a><br> <br> <p><strong>About the show</strong></p> <p>Sponsored by <strong>us:</strong></p> <ul> <li>Check out the <a href="https://training.talkpython.fm/courses/all"><strong>courses over at Talk Python</strong></a></li> <li>And <a href="https://pythontest.com/pytest-book/"><strong>Brian’s book too</strong></a>!</li> </ul> <p><strong>Brian #1:</strong> <a href="https://www.python.org/dev/peps/pep-0679/"><strong>(draft) PEP 679 -- Allow parentheses in assert statements</strong></a></p> <ul> <li>Pablo Galindo Salgado</li> <li>This is in draft, not approved, and not scheduled for any release</li> <li>But it seems like a really good idea to me.</li> <li><code>assert(1 == 2, "seems like it should fail")</code> will always pass currently</li> <li>since the tuple <code>(False,"seems like it should fail")</code> is a non-empty tuple.</li> <li>Current Python will emit a warning</li> </ul> <pre><code> &gt;&gt;&gt; assert(1 == 2, "seems like it should fail") [stdin]:1: SyntaxWarning: assertion is always true, perhaps remove parentheses? </code></pre> <ul> <li>But really, why not just change the language to allow <code>assert</code> with or without parens.</li> <li>Also would allow multi-line assert statements more easily:</li> </ul> <pre><code> assert ( very very long expression, "very very long " "message", ) </code></pre> <ul> <li>I hope this is a slam dunk and gets in ASAP.</li> </ul> <p><strong>Michael #2:</strong> <a href="https://localghost.dev/blog/everything-i-googled-in-a-week-as-a-professional-software-engineer/"><strong>Everything I googled as a dev</strong></a></p> <ul> <li>by Sophie Koonin</li> <li>In an attempt to dispel the idea that if you have to google stuff you’re not a proper engineer, this is a list of nearly everything I googled in a week at work</li> <li>Rather than my posting a huge list, check out the day logs on her post</li> <li>Worth calling out a few: <ul> <li><code>Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag?</code> - said React upgrade then started causing some super fun errors.</li> <li><code>semantic HTML contact details</code> - wanted to check if the <code>[HTML_REMOVED]</code> tag was relevant here</li> <li><code>editing host file</code> - desperate times (and it didn’t even work)</li> </ul></li> </ul> <p><strong>Madison #3:</strong> <a href="https://2022.pycascades.com/"><strong>PyCascades 2022!</strong></a></p> <ul> <li>Another year of excellent and diverse talks across an array of subjects.</li> <li>Talks from some well known folks (<a href="https://2022.pycascades.com/program/talks/supporting-the-george-floyd-protests-in-portland-demonstrations-legal-support-and-django-apps/">Thursday Bram</a>, <a href="https://2022.pycascades.com/program/talks/diversity-in-neurodiversity-help-for-underrepresented-folks-in-tech-and-allies-with-new-mental-health-diagnoses/">Jay Miller</a>) as well as first time speakers (<a href="https://2022.pycascades.com/program/talks/how-not-to-start-a-python-user-group/">Joseph Riddle</a>, <a href="https://2022.pycascades.com/program/talks/council-data-project-infrastructure-as-code-for-civic-transparency-and-accessibility/">Isaac Na</a>) <ul> <li>PSF’s DE&amp;I Panel is doing a meet &amp; greet, and they have <a href="https://docs.google.com/forms/d/e/1FAIpQLSc8957QqYuPDF2qL8Q2ctFzBH_mPMi0yxSQ2oqOACTU9jIVDg/viewform">a survey they’d like Python community members to fill out</a>.</li> </ul></li> <li>Socials Friday &amp; Saturday night, sprints on Sunday.</li> <li><a href="https://pretix.eu/pycascades/remote-2022/">Tickets are still available!</a></li> </ul> <p><strong>Brian #4:</strong> <a href="https://sethmlarson.dev/blog/strict-python-function-parameters"><strong>Strict Python function parameters</strong></a></p> <ul> <li>Seth Michael Larson</li> <li>We have keyword only parameters <ul> <li><code>def process_data(data, *, encoding="ascii"): ...</code></li> <li>notice the <code>*</code></li> <li><code>encoding</code> has to be a keyword argument, cannot be positional.</li> </ul></li> <li>We have position only parameters: <ul> <li><code>def process_data(data, /, encoding="ascii"): ...</code> </li> <li>notice the <code>/</code></li> <li><code>data</code> has to be positional, cannot be passed in as a keyword argument</li> </ul></li> <li>Combine the two: <ul> <li><code>def process_data(data, /, *, encoding="ascii"): ...</code></li> <li>Now <code>data</code> has to be positional, and <code>encoding</code> has to be a keyword, if present.</li> </ul></li> <li>This way a function really can only be called as intended and all uses of the function will be consistent. This is a good thing.</li> <li>There are many benefits, including <a href="https://www.python.org/dev/peps/pep-0570/#empowering-library-authors">empowering library authors</a> to make changes without weird behaviors cropping up in user code.</li> <li>Commentary: <ul> <li>extra syntax may be confusing for some new users. </li> <li>For a lot of library API entry points, I think this makes a lot of sense.</li> </ul></li> </ul> <p><strong>Michael #5:</strong> <a href="https://github.com/slingamn/mureq"><strong>mureq</strong></a> <strong>- vendored requests</strong></p> <ul> <li><code>mureq</code> is a single-file, zero-dependency alternative to <a href="https://github.com/psf/requests">python-requests</a></li> <li>Intended to be vendored in-tree by Linux systems software and other lightweight applications.</li> <li>Doesn’t support connection pooling (but neither does <code>requests.get()</code>).</li> <li>Uses much less memory</li> <li>Avoids supply chain attack vulnerabilities </li> <li>Consider <a href="https://github.com/mikeckennedy/mureq/tree/prod"><strong>my prod branch</strong></a> until PRs <a href="https://github.com/slingamn/mureq/pull/2"><strong>#2</strong></a> and <a href="https://github.com/slingamn/mureq/pull/3"><strong>#3</strong></a> are merged.</li> </ul> <p><strong>Madison #6</strong>: <a href="https://make.wordpress.org/openverse/2022/01/25/everything-you-need-to-know-about-openverse-and-the-wordpress-photo-directory/"><strong>Openverse</strong></a></p> <ul> <li>No, not Metaverse!</li> <li>Previously <a href="https://creativecommons.org/2021/12/13/dear-users-of-cc-search-welcome-to-openverse/">“CC Search”</a></li> <li>Search engine for openly licensed media, for <a href="https://creativecommons.org/use-remix/">free and public</a> use/remix of content.</li> <li>Currently images &amp; audio, hope to include video, text, 3D models down the line.</li> <li><a href="http://wp.org/openverse">Start your search here</a></li> </ul> <p><strong>Extras</strong> </p> <p>Michael:</p> <ul> <li>We now have playable times in the transcript section (<a href="https://pythonbytes.fm/episodes/transcript/267/python-on-the-beach"><strong>example</strong></a>).</li> <li>Very cool tool for building regex-es I used for the above: <a href="https://regex101.com/r/BRaEMy/1"><strong>regex101.com</strong></a></li> <li>Next video is out: <a href="https://www.youtube.com/watch?v=uVQVn8z8kxo"><strong>Do you even need loops in Python? A Python short by Michael Kennedy</strong></a></li> <li>Remember, we have full-text search</li> </ul> <p>Brian:</p> <ul> <li><a href="https://github.com/marketplace/actions/pip-secure-install">pip-secure-install</a> - from Brett Cannon</li> <li><a href="https://pragprog.com/titles/bopytest2/python-testing-with-pytest-second-edition/">Python Testing with pytest</a> is, when I last checked, the <a href="https://pragprog.com/best_sellers/">#2 bestseller at Pragmatic</a> <ul> <li>so cool</li> <li>My Maui trip was also a work trip. Gave me time to completely re-read the book, make notes, and make last minute changes. Changes went in this week and tonight is my “pencils down” date. This is getting real, folks. </li> <li>Thanks to everyone for buying beta copies and supporting the re-write. </li> </ul></li> </ul> <p>Madison:</p> <ul> <li><a href="https://spd.watch">spd.watch</a> - new police accountability/information tool for the Seattle area</li> <li>Shoutout to <a href="https://github.com/casey/just">just</a> (mentioned in <a href="https://pythonbytes.fm/episodes/show/242/from-lib-import-but-less">Ep 242</a>)</li> <li><a href="https://ghcr.io">ghcr.io</a> - free docker image hosting for open source projects, easy integration with GitHub Actions</li> </ul> <p><strong>Joke:</strong> </p> <p>via Josh Thurston</p> <ul> <li>How did the hacker get away from the police? He just ransomware.</li> <li>That joke makes me WannaCry…</li> <li>Where do you find a hacker? In decrypt.</li> </ul>

from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...