Python Bytes: #320 The Bug Is In The JavaScript :

Python Bytes: #320 The Bug Is In The JavaScript
by:
blow post content copied from  Planet Python
click here to view original post


<a href='https://www.youtube.com/watch?v=uy04vHILEtY' 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 &amp; Code</strong></a> Podcast</li> <li><a href="https://www.patreon.com/pythonbytes"><strong>Patreon Supporters</strong></a></li> </ul> <p><strong>Connect with the hosts</strong></p> <ul> <li>Michael: <a href="https://fosstodon.org/@mkennedy"><strong>@[email protected]</strong></a></li> <li>Brian: <a href="https://fosstodon.org/@brianokken"><strong>@[email protected]</strong></a></li> <li>Show: <a href="https://fosstodon.org/@pythonbytes"><strong>@[email protected]</strong></a></li> </ul> <p>Join us on YouTube at <a href="https://pythonbytes.fm/stream/live"><strong>pythonbytes.fm/stream/live</strong></a> to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.</p> <p><strong>Brian #1:</strong> <a href="https://github.com/executablebooks/markdown-it-py"><strong>markdown-it-py</strong></a></p> <ul> <li>Yes. another markdown parser.</li> <li><a href="https://github.com/Textualize/rich/releases/tag/v13.2.0">Rich recently switched markdown parsers</a>, from <code>commonmark</code> to <code>markdown-it-py</code>.</li> <li>Let’s look at those a bit.</li> </ul> <p><strong>Michael #2:</strong> <a href="https://github.com/approximatelabs/sketch"><strong>Sketch</strong></a></p> <ul> <li>via Jake Firman</li> <li>Sketch is an AI code-writing assistant for pandas users that understands the context of your data</li> <li>A Natural Language interface that successfully navigates many tasks in the data stack landscape. <ul> <li>Data Cataloging: <ul> <li>General tagging (eg. PII identification)</li> <li>Metadata generation (names and descriptions)</li> </ul></li> <li>Data Engineering: <ul> <li>Data cleaning and masking (compliance)</li> <li>Derived feature creation and extraction</li> </ul></li> <li>Data Analysis: <ul> <li>Data questions</li> <li>Data visualization</li> </ul></li> </ul></li> <li>Watch the video on the GitHub page for a quick intro</li> </ul> <p><strong>Brian #3:</strong> <a href="https://pythontest.com/fix-circular-import-python-typing-protocol/"><strong>Fixing Circular Imports in Python with Protocol</strong></a></p> <ul> <li>Built on <a href="https://hynek.me/articles/python-subclassing-redux/"><strong>Subclassing in Python Redux</strong></a> from Hynek <ul> <li>We covered this in the summer of 2021, <a href="https://pythonbytes.fm/episodes/show/240/this-is-github-your-pilot-speaking">episode 240</a></li> <li>However, I re-read it recently due to a typing problem</li> <li>Problem is when an object passes itself to another module to be called later. <ul> <li>This is common in many design patterns, including just normal callback functions.</li> <li>Normally not a problem with Python, due to duck typing.</li> <li>But with type hints, suddenly it seems like both modules need types from the other.</li> </ul></li> <li>So how do you have two modules use types from each other without a circular import.</li> <li>Hynek produces two options <ul> <li>Abstract Data Types, aka Interfaces, using the <code>abc</code> module <ul> <li>Requires a third interface class</li> </ul></li> <li>Structural subtyping with <code>Protocol</code> <ul> <li>This is what I think I’ll use more often and I’m kinda in love with it now that I understand it.</li> <li>Still has a third type, but one of the modules doesn’t have to know about it.</li> </ul></li> <li>"<strong>Structural Subtyping :</strong> <em>Structural subtyping</em> is <em>duck typing</em> for types: if your class fulfills the constraints of a <code>[Protocol](https://ift.tt/H5OV1Sm>, it’s automatically considered a subtype of it. Therefore, a class can implement <em>many</em> <code>Protocol</code>s from all kinds of packages without knowing about them!”</li> </ul></li> </ul></li> <li>The <a href="https://pythontest.com/fix-circular-import-python-typing-protocol/">Fixing Circular Imports in Python with Protocol</a> article walks through one example of two classes talking with each other, typing, circular imports, and fixing them with Protocol</li> </ul> <p><strong>Michael #4:</strong> <a href="https://github.com/salabim/unrepl"><strong>unrepl</strong></a></p> <ul> <li>via/by Ruud van der Ham</li> <li><p>We’ve seen the code samples:</p> <div class="codehilite"> <pre><span></span><code><span class="o">&gt;&gt;&gt;</span> <span class="n">board</span> <span class="o">=</span> <span class="p">[]</span> <span class="o">&gt;&gt;&gt;</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span> <span class="o">...</span> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;_&#39;</span><span class="p">]</span> <span class="o">*</span> <span class="mi">3</span> <span class="o">...</span> <span class="n">board</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">row</span><span class="p">)</span> <span class="o">...</span> <span class="o">&gt;&gt;&gt;</span> <span class="n">board</span> <span class="p">[[</span><span class="s1">&#39;_&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;_&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;_&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">]]</span> <span class="o">&gt;&gt;&gt;</span> <span class="n">board</span>\<span class="p">[</span><span class="mi">2</span>\<span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;X&#39;</span> <span class="o">&gt;&gt;&gt;</span> <span class="n">board</span> <span class="p">[[</span><span class="s1">&#39;_&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;_&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;X&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">]]</span> </code></pre> </div></li> <li><p>But you cannot <em>really</em> run this code. You can’t paste it into a REPL yourself nor can you put it into a .py file.</p></li> <li>So you unrepl it: <strong>Copying the above code to the clipboard and run unrepl</strong>.</li> <li>Paste the result and now you can.</li> <li>Unrepl can be used as a command line tool but also as a module.</li> <li>The REPL functionality of underscore (_) to get access to the last value is also supported.</li> </ul> <p><strong>Extras</strong> </p> <p>Michael:</p> <ul> <li>You'll want to update your git ASAP.</li> <li>Get course releases at Talk Python <a href="https://training.talkpython.fm/courses/rss">via RSS</a></li> <li><a href="https://fosstodon.org/@cobler/109718505946298680">Gist</a> for using Turnstile with Python + Pydantic</li> </ul> <p><strong>Joke:</strong> <a href="https://www.youtube.com/watch?v=jxi0ETwDvws">there's a bug in the js</a></p> <ul> <li>You’ve checked all your database indexes, </li> <li>You’ve tuned all your API hooks,</li> <li>You’re starting to think</li> <li>That you might need a drink,</li> <li>Because there’s only one place left to look:</li> <li>…</li> <li>There must be a bug in the javascript</li> <li>Because everything else was built properly</li> <li>But the frontend’s a pile of crap ;)</li> </ul>
January 24, 2023 at 01:30PM
Click here for more details...

=============================
The original post is available in Planet Python by
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Salesforce