<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Oop on The Edge Cases</title>
    <link>https://www.kylestratis.com/tags/oop/</link>
    <description>Recent content in Oop on The Edge Cases</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>© 2025</copyright>
    <lastBuildDate>Fri, 18 Sep 2026 22:04:36 -0400</lastBuildDate>
    <atom:link href="https://www.kylestratis.com/tags/oop/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Overriding Class Methods in Python</title>
      <link>https://www.kylestratis.com/notes/overriding-class-methods-in-python/</link>
      <pubDate>Thu, 04 Jan 2024 05:42:19 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/overriding-class-methods-in-python/</guid>
      <description>&lt;p&gt;In order to override a class method, the overriding method should also be decorated as a class method and take a required parameter &lt;code&gt;cls&lt;/code&gt;, from which you can get class attributes. This is important to keep in mind when overriding things like PynamoDB models.&lt;/p&gt;&#xA;&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-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:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;OverridingClass&lt;/span&gt;(Model):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;__init__&lt;/span&gt;(self, &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;args, &lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;kwargs):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        super()&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;__init__&lt;/span&gt;(&lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;args, &lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;kwargs)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;@classmethod&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;classmethod&lt;/span&gt;(cls, &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;args, &lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;kwargs):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        class_attribute_example &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; cls&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;class_attribute&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; super()&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;classmethod(&lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;args, &lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;kwargs)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>Unpacking Object Parameters in Python</title>
      <link>https://www.kylestratis.com/notes/unpacking-object-parameters-in-python/</link>
      <pubDate>Fri, 04 Mar 2022 21:20:19 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/unpacking-object-parameters-in-python/</guid>
      <description>&lt;p&gt;In Python, if two objects have the same parameters, you can unpack the output of the &lt;code&gt;__dict__&lt;/code&gt; method of an instance of one into the constructor of another to transmute an object.&lt;/p&gt;&#xA;&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-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:#75715e&#34;&gt;## Create an instance of Class B using the properties of an instance of Class A&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;b &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; ClassB(&lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;instance_a&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;__dict__)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>Imports and Class Instances</title>
      <link>https://www.kylestratis.com/notes/imports-and-class-instances/</link>
      <pubDate>Fri, 04 Mar 2022 21:17:11 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/imports-and-class-instances/</guid>
      <description>&lt;p&gt;In Python, if you return a class instance, that instance has everything a consumer needs to use it. So for instance, if I pass a PynamoDB model object (indicating a document in DynamoDB) back to a consumer, they&amp;rsquo;ll be able to use it without importing Pynamo directly.&lt;/p&gt;&#xA;&lt;h2 id=&#34;source&#34;&gt;Source&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://stackoverflow.com/questions/27991552/when-does-a-passed-class-instance-require-an-import-in-python&#34;&gt;https://stackoverflow.com/questions/27991552/when-does-a-passed-class-instance-require-an-import-in-python&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
    </item>
  </channel>
</rss>
