<p><strong>Watch the live stream:</strong></p>
<a href='https://www.youtube.com/watch?v=U6KDaVWw0ko' style='font-weight: bold;'>Watch on YouTube</a><br>
<br>
<p><strong>About the show</strong></p>
<p>Sponsored by us! Support our work through:</p>
<ul>
<li>Our <a href="https://training.talkpython.fm/"><strong>courses at Talk Python Training</strong></a></li>
<li><a href="https://testandcode.com/"><strong>Test & Code</strong></a> Podcast</li>
<li><a href="https://www.patreon.com/pythonbytes"><strong>Patreon Supporters</strong></a></li>
</ul>
<p><strong>Michael #1:</strong> <a href="https://wagenrace.github.io/python_dep_frontend/"><strong>Python License tracker</strong></a></p>
<ul>
<li>by Tom Nijhof/Nyhof</li>
<li>Every package depends on other package with sometimes different licenses.</li>
<li>Tom made a tool to find out what licenses you all need for a project:</li>
<li>PyTest alone needs 4 different licenses for itself and its dependencies.</li>
<li>Tensorflow is even worst</li>
</ul>
<p><strong>Brian #2:</strong> <a href="https://www.pythonmorsels.com/undataclass/"><strong>undataclass</strong></a></p>
<ul>
<li>Trey Hunner</li>
<li>As a teaching aid, and to show how much dataclasses do for you, this is a module and an application that converts dataclasses to normal classes, and fills in all of the dunder methods you need.</li>
<li><p>Example in app:</p>
<pre><code>from dataclasses import dataclass
@dataclass()
class Point:
x: float
y: float
z: float
</code></pre></li>
<li><p>Converts to</p>
<pre><code>class Point:
__match_args__ = ('x', 'y', 'z')
def __init__(self, x: float, y: float, z: float) -> None:
self.x = x
self.y = y
self.z = z
def __repr__(self):
cls = type(self).__name__
return f'{cls}(x={self.x!r}, y={self.y!r}, z={self.z!r})'
def __eq__(self, other):
if not isinstance(other, Point):
return NotImplemented
return (self.x, self.y, self.z) == (other.x, other.y, other.z)
</code></pre></li>
<li><p>Note on <code>NotImplemented</code>:</p>
<ul>
<li>It just means, “I don’t know how to compare this”, and Python will try <code>__eq__</code> on the <code>other</code> object. If that also raises <code>NotImplemented</code>, a <code>False</code> is returned. </li>
</ul></li>
<li>The default is the above with <code>@dataclass(frozen=True, slots=True)</code> and adds the methods:
<ul>
<li><code>fronzen=True</code> gives you implementations of <code>__hash__</code>, <code>__setattr__</code>, <code>__delattr__</code>, <code>__getstate__</code>, <code>__setstate__</code>,
<ul>
<li>Essentially raises exception if you try to change the contents, and makes your objects hashable. </li>
</ul></li>
<li><code>slots=True</code> adds the line: <code>__slots__ = (``'``x',</code> <code>'``y``'``,</code> <code>'``z``'``)</code>.
<ul>
<li>This disallows adding new attributes to objects at runtime. See <a href="https://docs.python.org/3.10/reference/datamodel.html#slots">Python docs</a></li>
</ul></li>
</ul></li>
<li>Trey wrote two posts about it:
<ul>
<li><a href="https://www.pythonmorsels.com/match-case-parsing-python/">Appreciating Python's match-case by parsing Python code</a></li>
<li><a href="https://www.pythonmorsels.com/making-a-dataclass-remover/">How I made a dataclass remover</a></li>
</ul></li>
<li>Turns out, this is a cool example for AST and structural pattern matching.</li>
<li>Notes from the “how I made..” article:</li>
<li>"I used some tricks I don't usually get to use in Python. I used:</li>
<li>Many <strong>very hairy</strong> <code>**match**</code><strong>-</strong><code>**case**</code> <strong>blocks</strong> which replaced even hairier <code>if</code>-<code>elif</code> blocks</li>
<li>A <strong>sentinel object</strong> to keep track of a location that needed replacing</li>
<li>Python's <code>**textwrap.dedent**</code> <strong>utility</strong>, which I feel should be more widely known & used</li>
<li><strong>slice assignment</strong> to inject one list into another</li>
<li>The <code>ast</code> module's <code>unparse</code> function to convert an abstract syntax tree into Python code”</li>
</ul>
<p><strong>Michael #3:</strong> <a href="https://qutebrowser.org"><strong>Qutebrowser</strong></a></p>
<ul>
<li>via Martin Borus</li>
<li>Qutebrowser is a keyboard-focused browser with a minimal GUI."</li>
<li>It's Python powered </li>
<li>Whats more important - doesn't force you to use it's Vim-based shortcuts, the mouse</li>
<li>still works. But you usually don't need it: Because on any page, a keypress on the "f" key will show, you every clickable think and a letter combination to enter to click this.</li>
</ul>
<p><strong>Brian #4:</strong> <strong>asyncio and web applications</strong></p>
<ul>
<li>A collection of articles</li>
<li><a href="https://palletsprojects.com/blog/quart-pallets/">Quart is now a Pallets project</a>
<ul>
<li>P G Jones, maintainer of Quart and Hypercorn</li>
<li>“Quart, an ASGI re-implementation of the Flask API has joined the Pallets organization. This means that future development will be under the Pallets governance by the Pallets maintainers.</li>
<li>Our long term aim is to merge Quart and Flask to bring ASGI support directly to Flask. </li>
<li>“When to use Quart?”
<ul>
<li>“Quart is an ASGI framework utilising async IO throughout, whereas Flask is a WSGI framework utilising sync IO. It is therefore best to use Quart if you intend to use async IO (i.e. async/await libraries) and Flask if not. Don't worry if you choose the 'wrong' framework though, as Quart supports sync IO and Flask supports async IO, although less efficiently.”</li>
</ul></li>
</ul></li>
<li><a href="https://flask.palletsprojects.com/en/2.1.x/async-await/">Using async and await</a>, from Flask docs
<ul>
<li>Flask has some support of async/await since Flask 2.0</li>
<li>But it’s still a WSGI application.</li>
<li>“Deciding whether you should use Flask, Quart, or something else is ultimately up to understanding the specific needs of your project.”</li>
</ul></li>
<li><a href="https://www.laac.dev/blog/should-you-use-asyncio-next-python-web-application/">Should You Use AsyncIO for Your Next Python Web Application?</a>
<ul>
<li>Steven Pate</li>
<li>A cool “brief history of Python web server interfaces”</li>
<li>Discussion of the Python servers and frameworks for both WSGI and ASGI</li>
<li>Recommendation: Do you need async? “… most people don’t. WSGI servers and frameworks are usually performant enough.”</li>
</ul></li>
</ul>
<p><strong>Extras</strong> </p>
<p>Michael:</p>
<ul>
<li>Python Web Conf Talk: <a href="https://www.youtube.com/watch?v=-qU3cfU35OE"><strong>HTMX + Flask: Modern Python Web Apps, Hold the JavaScript</strong></a></li>
<li><a href="https://github.com/will-stone/browserosaurus">browserosaurus</a></li>
</ul>
<p><strong>Joke:</strong> <a href="https://twitter.com/PR0GRAMMERHUM0R/status/1542855590753583104"><strong>Understanding JavaScript</strong></a></p>
<p><strong>Joke:</strong> <a href="https://www.neta.mk/archive"><strong>Where do you see yourself in 5 years?</strong></a></p>
<p><img src="https://paper-attachments.dropbox.com/s_2B2DA5ABAB520A067C7A455F46C098AF9EB6B5C867D3A5122B548BFAFDACC225_1657115556852_image.png" alt="" /></p>
↧