Wednesday, September 22, 2021

Python Bytes: #251 A 95% complete episode (wait for it)

<p><strong>Watch the live stream:</strong></p> <a href='https://www.youtube.com/watch?v=ssB7SouW1tk' 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>Special guest: <strong><a href="https://twitter.com/brettsky">Brett Cannon</a></strong></p> <p><strong>Michael #1:</strong> <a href="https://auto-optional.daanluttik.nl/"><strong>auto-optional</strong></a></p> <ul> <li>by Daan Luttik</li> <li>Did you know that concrete types cannot be None in Python typing?</li> <li>This is wrong:</li> </ul> <pre><code> def do_a_thing(extra_info: str = None): ... </code></pre> <ul> <li>auto-optional will fix it:</li> </ul> <pre><code> def do_a_thing(extra_info: Optional[str] = None): ... </code></pre> <ul> <li>Why would you want this?</li> <li>Easily modify external libraries that didn't pay attention to proper use of optional to improve mypy linting.</li> <li>Force consistency in your own code-base: Enforcing that None parameter implies an Optional type.</li> <li>Run via the CLI: <code>auto-optional [path]</code></li> </ul> <p><strong>Brian #2:</strong> <a href="https://daniel.haxx.se/blog/2021/09/04/making-world-class-docs-takes-effort"><strong>Making World-Class Docs Takes Effort</strong></a></p> <ul> <li>Daniel Stenberg</li> <li>Six requirements for a project to get a gold star <ul> <li>docs in the code repo</li> <li>NOT extracted from the code</li> <li>examples, lots of examples, more than you think you need</li> <li>document every API call you provide</li> <li>easily accessible and browsable</li> <li>and hopefully offline readable as well</li> <li>easy to contribute to</li> </ul></li> <li>Non-stop iterating is key to having good docs.</li> <li>extra goodness <ul> <li>consistency for section titles</li> <li>cross-references</li> </ul></li> <li>I’d add <ul> <li>Check for grammar and spelling mistakes</li> <li>Consistency in all things, formatting, style, tone, depth of info of diff topics</li> <li>Don’t be afraid to have a personality. docs that include easter eggs, fun examples, tasteful jokes, etc are nice, as long as that fun stuff doesn’t complicate the docs.</li> <li>Don’t slam projects for having bad docs. Not all open source projects exist for your benefit. <ul> <li>You can make them better by contributing. :)</li> </ul></li> </ul></li> </ul> <p><strong>Brett #3:</strong> <a href="https://starship.rs/"><strong>Starship</strong></a></p> <ul> <li>Continuing the trend of stuff to help make your coding better, Python or not. 😉</li> <li>Also to make Michael’s new love of nerd fonts more useful. 😁</li> <li>And more Rust on this show as Paul Everitt says I must do. 😉</li> <li>Gives you a common shell prompt no matter which shell you use; I also find it easy to set up compared to most shells for their prompts</li> <li>Lots of integrated support for various developer things such as printing what Python version you have when the directory has a <code>pyproject.toml</code> file.</li> <li>Works nicely with the Python Launcher (as I mentioned the last time I was on).</li> <li>Has some pyenv support that I don’t use. 😁</li> </ul> <p><strong>Michael #4:</strong> <a href="https://pypi.org/project/jmespath/"><strong>JMESPath</strong></a></p> <ul> <li>via Josh Thurston</li> <li>Spent tons of time figuring out how to parse the pretty print results that had layers of nested dictionaries and lists. This module saved me time in a big way.</li> <li>JMESPath (pronounced “james path”) allows you to declaratively specify how to extract elements from a JSON document.</li> <li>For example, given this document:</li> </ul> <pre><code> {"foo": {"bar": "baz"}} </code></pre> <ul> <li>The jmespath expression <code>foo.bar</code> will return “baz”.</li> <li>Even works with a projection-like result:</li> </ul> <pre><code> {"foo": {"bar": [{"name": "one"}, {"name": "two"}]}} </code></pre> <ul> <li>The expression: <code>foo.bar[*].name</code> will return <code>["one", "two"]</code>. </li> <li>Negative indexing is also supported (-1 refers to the last element in the list). </li> <li>Given the data above, the expression <code>foo.bar[-1].name</code> will return <code>"two"</code>.</li> </ul> <p><strong>Brian #5:</strong> <a href="https://github.com/spotify/pedalboard"><strong>pedalboard</strong></a> - audio effects library</p> <ul> <li>from Spotify</li> <li>The “power, speed, and sound quality of a DAW”, but in Python.</li> <li><a href="https://engineering.atspotify.com/2021/09/07/introducing-pedalboard-spotifys-audio-effects-library-for-python">Introduction Article</a> (warning: weird color changing header image that is painful to look at, so scroll past that quickly) <ul> <li>Built-in support for a number of basic audio transformations:</li> <li><code>Convolution</code>, <code>Compressor</code>, <code>Chorus</code>, <code>Distortion</code></li> <li><code>Gain</code>, <code>HighpassFilter</code>, <code>LadderFilter</code>, <code>Limiter</code>, <code>LowpassFilter</code></li> <li><code>Phaser</code>, <code>Reverb</code></li> </ul></li> </ul> <p><strong>Brett #6:</strong> <a href="https://www.python.org/dev/peps/pep-0665/"><strong>PEP 665</strong></a> <strong>(and the</strong> <a href="https://discuss.python.org/t/pep-665-specifying-installation-requirements-for-python-projects/9911/152"><strong>journey so far</strong></a><strong>)</strong></p> <ul> <li>Attempt to standardize lock files for Python.</li> <li>Spent six months talking w/ folks privately to come up with the first public draft.</li> <li>Initially a strict lock file, but Poetry and PDM feedback was platform-agnostic was important.</li> <li>Proposal morphed to cover that.</li> <li>Took it public and led to over 150 comments on Discourse.</li> <li>People disliked it: from the title to the explanation to the proposed problem space to the actual solution.</li> <li>Gone back to the drawing board privately w/ one of the original objectors participating; looking like we are reaching a good consensus on how to frame things and how it should ultimately look.</li> <li>(Packaging) PEPs are hard.</li> </ul> <p><strong>Extras</strong></p> <p>Brian</p> <ul> <li>Python is popular, apparently, and <a href="https://www.zdnet.com/article/programming-languages-python-is-on-the-verge-of-another-big-step-forward/">“on the verge of another big step forward”</a> (another good place for dun, dun, duuunnn, ?) <ul> <li>"It only needs to bridge 0.16% to surpass C. This might happen any time now. If Python becomes number 1, a new milestone has been reached in the TIOBE index. Only 2 other languages have ever been leading the pack so far, i.e. C and Java."</li> </ul></li> </ul> <p>Michael</p> <ul> <li><a href="https://www.nerdfonts.com/"><strong>Nerd Fonts</strong></a></li> <li><a href="https://evrone.com/michael-kennedy-interview"><strong>Evrone interview with me</strong></a></li> <li><a href="https://twitter.com/HenrySchreiner3/status/1438227200466202625"><strong>Henry Schreiner’s Fish setup</strong></a></li> <li><a href="https://linuxize.com/post/how-to-create-bash-aliases/"><strong>Aliases rather than CLI/venvs</strong></a></li> </ul> <p>Brett</p> <ul> <li><a href="https://www.youtube.com/watch?v=1kTWxamIJ_k">Will McGugan did a webinar w/ Paul Everitt</a> about Textual (because it’s not a Python Bytes episode if Will’s name is not brought up).</li> <li>Python Launcher officially launched! (Last covered <a href="https://pythonbytes.fm/episodes/show/221/pattern-matching-and-accepting-change-in-python-with-brett-cannon">30 episodes ago</a>.) <ul> <li>Available in AUR, Fedora, and Homeberw (both macOS and Linux).</li> <li>No reported bugs since launch!</li> </ul></li> <li>Still doing my <a href="https://snarky.ca/tag/syntactic-sugar/">syntactic sugar blog posts</a>.</li> <li>The Python extension for VS Code has a <a href="https://code.visualstudio.com/docs/python/testing">refreshed testing UX</a>; we’re coming for you, Brian. 😉</li> </ul> <p><strong>Joke:</strong> <a href="https://geek-and-poke.com/geekandpoke/2021/2/2/the-last-5"><strong>Last 5%</strong></a></p>

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