<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Counter on SCMB XYZ</title>
    <link>https://www.scmb.xyz/tags/counter/</link>
    <description>Recent content in Counter on SCMB XYZ</description>
    <generator>Hugo</generator>
    <language>en-gb</language>
    <copyright>&amp;copy; Seamus Bradley 2021–6</copyright>
    <lastBuildDate>Fri, 27 Jan 2023 01:11:54 +0000</lastBuildDate>
    <atom:link href="https://www.scmb.xyz/tags/counter/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Python&#39;s Counter</title>
      <link>https://www.scmb.xyz/post/pythons-counter/</link>
      <pubDate>Fri, 27 Jan 2023 01:11:54 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/pythons-counter/</guid>
      <description>&lt;h1 id=&#34;the-problem&#34;&gt;The problem&lt;/h1&gt;&#xA;&lt;p&gt;Python has a &lt;code&gt;Counter&lt;/code&gt; object &amp;ndash; it&amp;rsquo;s found in&#xA;&lt;a href=&#34;https://docs.python.org/3/library/collections.html&#34;&gt;the &lt;code&gt;collections&lt;/code&gt; module&lt;/a&gt; &amp;ndash;&#xA;and I&amp;rsquo;ve become convinced that it&amp;rsquo;s&amp;hellip; a bit weird?&#xA;The basic idea is fine:&#xA;it&amp;rsquo;s a dictionary but the keys are things you want to count, and the values are the amount of&#xA;the thing you have counted.&#xA;The neat thing is if you initialise a counter with an iterable like a string or a list,&#xA;it&amp;rsquo;ll give you the counts for the number of times each element appears.&#xA;And it gives you convenience methods for finding the most common elements and that sort of thing.&#xA;It&amp;rsquo;s pretty neat and I&amp;rsquo;ve used it a few times.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
