<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Python on Living Systems_</title>
    <link>https://livesys.se/tags/python/</link>
    <description>Recent content in Python on Living Systems_</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 04 Mar 2024 14:42:00 +0100</lastBuildDate>
    <atom:link href="https://livesys.se/tags/python/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Debugging inside Jinja templates using pdb/ipdb</title>
      <link>https://livesys.se/posts/debugging-inside-jinja-templates-using-pdb-ipdb/</link>
      <pubDate>Mon, 04 Mar 2024 14:42:00 +0100</pubDate>
      <guid>https://livesys.se/posts/debugging-inside-jinja-templates-using-pdb-ipdb/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m working on a static reporting tool using the Jinja2 templating&#xA;engine for Python.&lt;/p&gt;&#xA;&lt;p&gt;I was trying to figure out a way to enter into the Jinja templating code&#xA;with the pdb/ipdb commandline debugger.&lt;/p&gt;&#xA;&lt;p&gt;I tried creating an &lt;code&gt;.ipdbrc&lt;/code&gt; file in my local directory with the line:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;path/to/template.html:&amp;lt;lineno&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&amp;hellip; but that didn&amp;rsquo;t work.&lt;/p&gt;&#xA;&lt;p&gt;What worked was to figure out &lt;a href=&#34;https://github.com/pallets/jinja/blob/main/src/jinja2/environment.py#L1301&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;the line that&#xA;says&lt;/a&gt;&#xA;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;return self.environment.concat(self.root_render_func(ctx))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&amp;hellip; inside the the jinja codebase, and put a breakpoint on that (which&#xA;for me was on line 1299, but might vary depending on version):&lt;/p&gt;</description>
    </item>
    <item>
      <title>Basic PUB/SUB connection with ZeroMQ in Python</title>
      <link>https://livesys.se/posts/pub-sub-with-zeromq-in-python/</link>
      <pubDate>Wed, 13 Nov 2019 11:56:00 +0100</pubDate>
      <guid>https://livesys.se/posts/pub-sub-with-zeromq-in-python/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://zeromq.org&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;ZeroMQ&lt;/a&gt;&#xA; is a great way to quickly and simply send messages&#xA;between multiple programs running on the same or different computers. It is&#xA;very simple and robust since it doesn&amp;rsquo;t need any central server. Instead it&#xA;talks directly between the programs through sockets, TCP-connections or&#xA;similar.&lt;/p&gt;&#xA;&lt;p&gt;ZeroMQ has client libraries for basically all commonly used programming&#xA;languages, but when testing out that a connection works between e.g. two&#xA;different machines, it might be good to keep things simple and test just&#xA;the connection, as simply as possible. For this purpose, I have came to&#xA;use the following two python scripts, where one sets up a &amp;ldquo;publisher&amp;rdquo;,&#xA;and the other a &amp;ldquo;subscriber&amp;rdquo; process. I&amp;rsquo;m documenting them here since&#xA;I tend to forget the syntax from time to time, and also some details,&#xA;such as that you have to make sure the subscriber subscribes to one or&#xA;all topics.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The unexpected convenience of JSON on the commandline</title>
      <link>https://livesys.se/posts/the-unexpected-usefullness-of-json-on-the-commandline/</link>
      <pubDate>Tue, 08 Dec 2015 07:10:00 +0100</pubDate>
      <guid>https://livesys.se/posts/the-unexpected-usefullness-of-json-on-the-commandline/</guid>
      <description>&lt;p&gt;I was working with a migration from &lt;a href=&#34;http://drupal.org&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;drupal&lt;/a&gt;&#xA; to&#xA;&lt;a href=&#34;http://processwire.com&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;processwire&lt;/a&gt;&#xA; CMS:es, where I wanted to be able&#xA;to pipe data, including the body field with HTML formatting and all,&#xA;through multiple processing steps in a flexible manner. I&amp;rsquo;d start with&#xA;an extraction SQL query, through a few components to replace and massage&#xA;the data, and finally over to an import command using processwire&amp;rsquo;s&#xA;&lt;a href=&#34;http://wireshell.pw&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;wireshell tool&lt;/a&gt;&#xA;. So, basically I needed a flexible&#xA;format for structured data that could be sent as one &amp;ldquo;data object&amp;rdquo; per&#xA;line, to work nicely with linux commandline tools like grep, sed and&#xA;awk.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to compile vim for use with pyenv and vim-pyenv</title>
      <link>https://livesys.se/posts/how-to-compile-vim-for-use-with-pyenv-and-vim-pyenv/</link>
      <pubDate>Thu, 20 Aug 2015 08:05:00 +0200</pubDate>
      <guid>https://livesys.se/posts/how-to-compile-vim-for-use-with-pyenv-and-vim-pyenv/</guid>
      <description>&lt;!-- raw HTML omitted --&gt;&#xA;&lt;p&gt;This manifested itself in a bunch of error message from the python&#xA;module in vim, ending with:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#000&#34;&gt;AttributeError&lt;/span&gt;: &lt;span style=&#34;color:#c41a16&#34;&gt;&amp;#39;module&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#a90d91&#34;&gt;object&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;has&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;no&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;attribute&lt;/span&gt; &lt;span style=&#34;color:#c41a16&#34;&gt;&amp;#39;vars&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I first thought it was an error in vim-pyenv and &lt;a href=&#34;https://github.com/lambdalisue/vim-pyenv/issues/14&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;reported&#xA;it&lt;/a&gt;&#xA; (see that issue&#xA;for more in-depth details). In summary it turns out that older versions&#xA;of VIM indeed lack some attributes in its python module, so I figured I&#xA;had to compile my own version, below are just my notes about how to do&#xA;this, for future reference:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
