<p><strong>Watch the live stream:</strong></p>
<a href='https://www.youtube.com/watch?v=fdtDfeYmdDU' style='font-weight: bold;'>Watch on YouTube</a><br>
<br>
<p><strong>About the show</strong></p>
<p>Sponsored by the <a href="https://pythonbytes.fm/irl"><strong>IRL Podcast from Mozilla</strong></a></p>
<p><strong>Brian #1:</strong> <a href="https://luminousmen.com/post/pip-constraints-files"><strong>Pip constraints files</strong></a></p>
<ul>
<li>by luminousmen</li>
<li>You can put some constraints on your dependencies with a <a href="https://pip.pypa.io/en/stable/user_guide/#constraints-files">constraints file</a>.</li>
<li>“Constraints files are requirements files that only control which version of a requirement is installed, not whether it is installed or not. “</li>
<li>Syntax is a subset of <code>requirements.txt</code> syntax
<ul>
<li>but all the restrictions seem reasonable, considering
<ul>
<li>must have a name</li>
<li>can’t be editable</li>
<li>can’t specify extras (that one is maybe slightly weird)</li>
</ul></li>
</ul></li>
<li>You can put <code>--constraint constraints.txt</code> right at the top of your <code>requirements.txt</code> file</li>
<li>or specify it on command line,
<ul>
<li><code>pip install --constraint constraints.txt -r requirements.txt</code></li>
</ul></li>
<li>Or, my favorite, stick it at the top of <code>requirements.in</code> file.
<ul>
<li>yes. <code>pip-compile</code> correctly handles constraints when generating <code>requirements.txt</code>.</li>
</ul></li>
<li>Example
<ul>
<li>requirements.in
--constraint constraints.txt
typer</li>
<li>constraints.txt
click<8.1.3</li>
<li>Output from <code>pip-compile requirements.in</code>
<pre><code>#
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
#
# pip-compile requirements.in
#
click==8.1.2
# via
# -c constraints.txt
# typer
typer==0.6.1
# via -r requirements.in
</code></pre></li>
</ul></li>
</ul>
<p><strong>Michael #2:</strong> <a href="https://pypi.org/project/async-cache/"><strong>async-cache</strong></a></p>
<ul>
<li>A caching solution for asyncio</li>
<li>Quite simple but looks effective and flexible too</li>
<li>Example:
<pre><code># TTL Cache
from cache import AsyncTTL
@AsyncTTL(time_to_live=60, maxsize=1024)
async def func(*args, **kwargs):
"""
time_to_live : max time for which a cached result is valid
maxsize : max number of results that are cached.
if max limit is reached the oldest result is deleted.
"""
pass
</code></pre></li>
</ul>
<p><strong>Brian #3:</strong> <a href="https://guicommits.com/organize-python-code-like-a-pro/"><strong>Organize Python code like a PRO</strong></a> </p>
<ul>
<li>Guilherme Latrova</li>
<li>Yes, this is one author’s opinion. but…
<ul>
<li>lots of great advice</li>
<li>nothing too weird</li>
<li>no tool recommendations</li>
</ul></li>
<li>Recommendations of note
<ul>
<li>keep a <code>src</code> dir.
<ul>
<li>A cool and simple reason: it keeps your source code together in alphabetized IDEs.</li>
</ul></li>
<li>file/module names: plural except for config, main, core, or similar
<ul>
<li>slightly weird tangent that there are no files, there are modules. ok, whatever.</li>
<li>Also talking about directories as main modules. odd. but ok.</li>
</ul></li>
<li>functions/methods should be verbs </li>
<li>variables/constants should be nouns</li>
<li>Class names should be singular, unless the class really represents a container</li>
<li>The <code>__name__ == "__main__"</code> trick for modules.</li>
<li>The <code>__main__.py</code> entry point trick for modules/packages so that <code>-m mymodule</code> does something.</li>
</ul></li>
-
</ul>
<p><strong>Michael #4:</strong> <a href="https://github.com/jaraco/keyring"><strong>keyring</strong></a></p>
<ul>
<li>via Trent</li>
<li>The Python keyring library provides an easy way to access the system keyring service from python. It can be used in any application that needs safe password storage.</li>
<li>It’s also helpful in that it allows you to write your own backends. Useful for testing.</li>
<li>Basically create a dummy keychain that stores to a pytest temp_path fixture instead of cluttering the real keychain. </li>
<li>You could potentially write a backend to interact with any service such as 1Password. </li>
</ul>
<p><strong>Extras</strong> </p>
<p>Brian:</p>
<ul>
<li>I’m taking a class on FastAPI. The instructor is awesome!</li>
<li>Also, editing some pytest course video.</li>
</ul>
<p>Michael:</p>
<ul>
<li><a href="https://twitter.com/btskinn/status/1555336931931815936"><strong>Gitlab, you alright?</strong></a>?</li>
</ul>
<p><strong>Joke:</strong> </p>
<ul>
<li><a href="https://github.com/wesbos/dad-jokes"><strong>from a dad-jokes repo</strong></a>
<ul>
<li><strong>Q:</strong> How do programming pirates pass method parameters?</li>
<li><strong>A:</strong> Varrrrarrrgs.</li>
<li><strong>Q:</strong> How do you get the code for the bank vault?</li>
<li><strong>A:</strong> You checkout their branch.</li>
<li>"Unfortunately these jokes only work if you git them."</li>
</ul></li>
<li><a href="https://twitter.com/pr0grammerhum0r/status/1552519242989305856?s=12&t=edvc7bbtBYuatg7tNJkJ7g"><strong>Screw driver</strong></a></li>
</ul>
↧