<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>Little Pieces</title>
      <link>https://littlepieces.toga.cx</link>
      <description>Small notes about small code pieces</description>
      <generator>Zola</generator>
      <language>en</language>
      <atom:link href="https://littlepieces.toga.cx/rss.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Thu, 16 Apr 2026 00:00:00 +0000</lastBuildDate>
      <item>
          <title>Python multiline lines</title>
          <pubDate>Thu, 16 Apr 2026 00:00:00 +0000</pubDate>
          <author>Unknown</author>
          <link>https://littlepieces.toga.cx/posts/python-multiline-lines/</link>
          <guid>https://littlepieces.toga.cx/posts/python-multiline-lines/</guid>
          <description xml:base="https://littlepieces.toga.cx/posts/python-multiline-lines/">&lt;p&gt;There is some PEP8 saying that files shouldn&#x27;t be more than 79 columns of text, which I will agree with.&lt;&#x2F;p&gt;
&lt;p&gt;While building with nix, I come across its python linter shananagans.  I make my main nix flake have built-in scripts, for python we use &lt;em&gt;writers.writePython3Bin&lt;&#x2F;em&gt;, which lets me add dependancies and script text all in one place.&lt;&#x2F;p&gt;
&lt;p&gt;This goes through the python linters every time its rebuilt.  It&#x27;s very strict by default, and you can relax the rules, but I don&#x27;t want to.  The rules have coerced me into learning new things about python.&lt;&#x2F;p&gt;
&lt;p&gt;I don&#x27;t like vibe coding where it farts out code all day.  I rather know whats happening.  So, after months of messing with llm coding, I&#x27;ve learned to keep code it writes small.  Still, it gets out of hand, so I am constantly fighting for it not to write so much code.&lt;&#x2F;p&gt;
&lt;p&gt;It wrote my newest version of ai.py which is a simple script to take in some text (or image) and in the background give it to an llm, write out the output on the drive when its finished.  I don&#x27;t have to see it streaming.  It&#x27;s totally possibly its 100% trash, or its usual sneaky gaslighting ways, doing just enough to run, but bad things are suddly and stratigically hidden.  (not really stratigically but its very good at gaslighting).&lt;&#x2F;p&gt;
&lt;p&gt;The LLM wrote lines that are out of the &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;peps.python.org&#x2F;pep-0008&#x2F;&quot;&gt;PEP8 spec&lt;&#x2F;a&gt;.  There were a bunch over 79 columns of text, which the linter wont pass unless you relax it.&lt;&#x2F;p&gt;
&lt;p&gt;I asked an llm, and it would give me new formatting that fit.  This is what it said:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Depending on your preference for readability, here are the three best ways to break this line according to PEP 8 standards.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;option-1-using-parentheses-recommended&quot;&gt;Option 1: Using Parentheses (Recommended)&lt;&#x2F;h3&gt;
&lt;p&gt;Wrapping the expression in parentheses allows you to break the line wherever you like without using backslashes. This is the cleanest and most &quot;Pythonic&quot; approach.&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code data-lang=&quot;python&quot;&gt;image_path = (
    ingest_path if ingest_path and is_image_file(ingest_path) else None
)
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;option-2-standard-if-else-block&quot;&gt;Option 2: Standard &lt;code&gt;if&#x2F;else&lt;&#x2F;code&gt; Block&lt;&#x2F;h3&gt;
&lt;p&gt;If you are worried about the line length or the complexity of the one-liner, expanding it into a standard block is the most readable for other developers.&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code data-lang=&quot;python&quot;&gt;if ingest_path and is_image_file(ingest_path):
    image_path = ingest_path
else:
    image_path = None
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;option-3-backslash-continuation&quot;&gt;Option 3: Backslash Continuation&lt;&#x2F;h3&gt;
&lt;p&gt;You can use a backslash to tell Python the line continues, though this is generally less preferred than Option 1.&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code data-lang=&quot;python&quot;&gt;image_path = ingest_path if ingest_path and \
    is_image_file(ingest_path) else None
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;which-one-should-you-choose&quot;&gt;Which one should you choose?&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Choose &lt;strong&gt;Option 1&lt;&#x2F;strong&gt; if you want to keep the logic concise but satisfy the linter.&lt;&#x2F;li&gt;
&lt;li&gt;Choose &lt;strong&gt;Option 2&lt;&#x2F;strong&gt; if this code is part of a critical section where clarity and debuggability are more important than brevity.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;I liked the Option #2.  It looks better, is shorter, and easier to see what it is actually doing.  It&#x27;s also made me open up the PEP8 doc and start reading it.  It&#x27;s mad this doc much more interesting to read, it has lots of cool syntax tricks that I wouldn&#x27;t even thought of.  I think any one writting or reading Python is going to get a boost reading that PEP8 Python Style guide.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;references&quot;&gt;References&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;PEP 8 – Style Guide for Python Code&lt;&#x2F;strong&gt; &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;peps.python.org&#x2F;pep-0008&#x2F;&quot;&gt;https:&#x2F;&#x2F;peps.python.org&#x2F;pep-0008&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</description>
      </item>
      <item>
          <title>First little piece</title>
          <pubDate>Wed, 15 Apr 2026 00:00:00 +0000</pubDate>
          <author>Unknown</author>
          <link>https://littlepieces.toga.cx/posts/first-little-piece/</link>
          <guid>https://littlepieces.toga.cx/posts/first-little-piece/</guid>
          <description xml:base="https://littlepieces.toga.cx/posts/first-little-piece/">&lt;p&gt;A tiny first post so the blog has something to render.&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code data-lang=&quot;nix&quot;&gt;pkgs.mkShell {
  packages = with pkgs; [ zola rsync git ];
}
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;That is enough to begin.&lt;&#x2F;p&gt;
</description>
      </item>
    </channel>
</rss>
