<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sarath Kaul on Medium]]></title>
        <description><![CDATA[Stories by Sarath Kaul on Medium]]></description>
        <link>https://medium.com/@skaul05?source=rss-ee4a54b6bda3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LB_uBCHuzIyPCYx4kLLRww@2x.jpeg</url>
            <title>Stories by Sarath Kaul on Medium</title>
            <link>https://medium.com/@skaul05?source=rss-ee4a54b6bda3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 05:40:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@skaul05/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Stop Writing Dangerous Python File Scripts: Introducing Atomic Filesystem Transactions]]></title>
            <link>https://levelup.gitconnected.com/stop-writing-dangerous-python-file-scripts-introducing-atomic-filesystem-transactions-b53506c57d7f?source=rss-ee4a54b6bda3------2</link>
            <guid isPermaLink="false">https://medium.com/p/b53506c57d7f</guid>
            <dc:creator><![CDATA[Sarath Kaul]]></dc:creator>
            <pubDate>Wed, 21 Jan 2026 03:14:52 GMT</pubDate>
            <atom:updated>2026-01-21T03:24:45.249Z</atom:updated>
            <content:encoded><![CDATA[<p>You have likely written this script before.</p><p>You have a folder with 1,000 messy filenames (IMG_001.jpg, DSC_0492.jpg) and you write a quick Python script to organize them into folders by date. You import os and shutil, write a for loop, and hit run.</p><p>It works perfectly for the first 500 files.</p><p>Then, on file #501, disaster strikes. Maybe it’s a PermissionError. Maybe the disk is full. Maybe there is a typo in your path logic. The script crashes.</p><p><strong>Now you have a problem.</strong></p><p>You are left in a “corrupted state.” Half your files are in the new location, and half are in the old one. Your folder is a mess, and you can’t just re-run the script because it will fail on the files it already moved. You have to manually undo the changes or write a <em>new</em> script just to clean up the mess.</p><p>In the world of databases, we solved this decades ago with <strong>Transactions</strong>. If an error happens halfway through an SQL update, the database rolls back to the clean state as if nothing happened.</p><p>Why don’t we have this for the filesystem?</p><p>Now we do.</p><h3>The “Half-Baked” State Problem</h3><p>Let’s look at the dangerous way we usually handle batch operations.</p><pre>import shutil<br>from pathlib import Path<br><br># The &quot;Dangerous&quot; Approach<br>for file in Path(&quot;downloads&quot;).glob(&quot;*.jpg&quot;):<br>    # If this fails on file #50, you have a mess<br>    shutil.move(str(file), f&quot;images/{file.name}&quot;)<br></pre><p>If this script fails, there is no “Ctrl+Z” for your hard drive.</p><p>To make this safe manually, you would need to write complex try...except blocks, keep a log of every file you moved, and write a custom error handler to move them back in reverse order if an exception occurs. It is tedious, error-prone code that distracts from your actual goal.</p><h3>Enter fs-transaction</h3><p>I built <strong>fs-transaction</strong> to bring the peace of mind of Database Transactions to standard Python file operations.</p><p>It works on a simple premise: <strong>Deferred Execution</strong>. When you ask the library to move a file, it doesn’t touch the disk immediately. It verifies that the operation <em>can</em> be done (checking permissions, paths, and existence), and adds it to a queue.</p><p>Only when the code block finishes successfully does it “commit” the changes. If <em>any</em> error occurs during the process, it automatically rolls back any changes it made, leaving your folder exactly how it found it.</p><h3>How to use it</h3><p>First, install the library:</p><pre>pip install fs-transaction</pre><p>Now, we can rewrite our dangerous script using a safe context manager:</p><pre>from fs_transaction import Transaction<br><br># The &quot;Safe&quot; Approach<br>with Transaction() as t:<br>    for file in Path(&quot;downloads&quot;).glob(&quot;*.jpg&quot;):<br>        # This queues the move, but doesn&#39;t execute it yet<br>        t.move(file, f&quot;images/{file.name}&quot;)<br>        <br>    # &lt;-- The &quot;Commit&quot; happens automatically here.<br>    # If any line above failed, NOTHING would have moved.</pre><h3>The “Smart Staging” Feature</h3><p>Moving files is easy, but what about writing content? If you start overwriting a file and the script crashes, you usually end up with a half-written, corrupted file.</p><p>fs-transaction handles this with <strong>Smart Staging</strong>.</p><pre>with Transaction() as t:<br>    # 1. Writes to a hidden temporary file first<br>    t.write(&quot;config.json&quot;, &quot;{&#39;status&#39;: &#39;updated&#39;}&quot;)<br>    <br>    # 2. Renames the old config to backup<br>    t.move(&quot;config.json&quot;, &quot;config.json.bak&quot;)<br>    <br>    # 3. If everything above succeeds, the temp file <br>    # is instantly swapped into place.</pre><p>If your power goes out halfway through, you aren’t left with a broken config.json. You still have the old one.</p><h3>Under the Hood: The Command Pattern</h3><p>For those interested in the architecture (similar to how we explore access modifiers in Python), the library utilizes the <strong>Command Design Pattern</strong>.</p><p>Every operation you request (move, copy, write) creates an Action Object. Each object knows how to do three things:</p><ol><li><strong>Validate:</strong> Check if the source exists and the destination is free.</li><li><strong>Execute:</strong> Perform the shutil or os operation.</li><li><strong>Rollback:</strong> Undo the operation (e.g., move the file back).</li></ol><p>When you exit the with block, the Transaction Manager runs a &quot;Two-Phase Commit&quot;:</p><ol><li><strong>Phase 1 (Validation):</strong> It runs validate() on all queued actions. If any fail (e.g., &quot;File Not Found&quot;), the transaction aborts before a single file is touched.</li><li><strong>Phase 2 (Execution):</strong> It begins executing actions. If an error occurs here (e.g., “Disk Full”), it pauses and immediately calls rollback() on every action that had already succeeded, in reverse order.</li></ol><h3>Conclusion</h3><p>We shouldn’t treat filesystem scripts as “throwaway” code. Whether you are building data pipelines, organizing personal media, or writing deployment scripts, atomicity is a safety net you shouldn’t ignore.</p><p>You can find the project on GitHub and PyPI. Give it a try next time you need to move a thousand files.</p><ul><li><strong>GitHub:</strong> <a href="https://github.com/SKAUL05/fs-transaction">github.com/SKAUL05/fs-transaction</a></li><li><strong>PyPI:</strong> <a href="https://pypi.org/project/fs-transaction/">pypi.org/project/fs-transaction</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b53506c57d7f" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/stop-writing-dangerous-python-file-scripts-introducing-atomic-filesystem-transactions-b53506c57d7f">Stop Writing Dangerous Python File Scripts: Introducing Atomic Filesystem Transactions</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Algorithm Challenge: LRU Cache]]></title>
            <link>https://levelup.gitconnected.com/algorithm-challenge-lru-cache-a2979cda2a13?source=rss-ee4a54b6bda3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2979cda2a13</guid>
            <category><![CDATA[lru]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[cache]]></category>
            <dc:creator><![CDATA[Sarath Kaul]]></dc:creator>
            <pubDate>Fri, 27 Dec 2024 02:32:15 GMT</pubDate>
            <atom:updated>2024-12-27T02:32:15.277Z</atom:updated>
            <content:encoded><![CDATA[<p>Implement Least Recently Used (LRU) Cache in Python</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RCPqz3frD32_TtdE" /><figcaption>Photo by <a href="https://unsplash.com/@jplenio?utm_source=medium&amp;utm_medium=referral">Johannes Plenio</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>Problem Statement</strong></h4><p>We need to implement an LRU Cache Class having the following properties</p><ul><li>Initialise the Cache to store data with size capacity</li><li>Implementing a get function to retrieve the value of the key if it exists otherwise return -1</li><li>Implement add functionality that updates the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key</li></ul><blockquote><strong><em>Achieve each operation in O(1) Time Complexity</em></strong></blockquote><h4><strong>The Challenge</strong></h4><p>Managing a fixed-size cache while maintaining quick access to elements is a common problem in system design. The challenge here is to ensure that all operations — get and add—are performed in constant time. To achieve this, we leverage <strong>Python’s OrderedDict</strong> from the collections module, which maintains the order of elements based on insertion.</p><h4>Implementation in Python</h4><p>Below is the Python implementation of an <strong>LRU Cache</strong> using an OrderedDict.</p><pre>import collections<br><br><br>class LRU:<br>    &quot;&quot;&quot; Least Recently Used Cache &quot;&quot;&quot;<br><br>    def __init__(self, capacity: int):<br>        &quot;&quot;&quot; Initialize cache to store data<br><br>        :param capacity: cache size<br>        &quot;&quot;&quot;<br>        self.remaining = capacity<br>        self.lru_cache = collections.OrderedDict()<br><br>    def get(self, key: int) -&gt; int:<br>        &quot;&quot;&quot; Return the value of key in cache<br>        :param key: Search key<br>        :return: Value<br>        &quot;&quot;&quot;<br>        if key in self.lru_cache:<br>            value = self.lru_cache.pop(key)<br>            self.lru_cache[key] = value<br>            return value<br>        return -1<br><br>    def add(self, key: int, value: int) -&gt; None:<br>        &quot;&quot;&quot; Add value in cache if not exists otherwise update the current value<br>        :param key: Cache Key<br>        :param value: Cache Value<br>        :return:<br>        &quot;&quot;&quot;<br>        if key in self.lru_cache:<br>            self.lru_cache.pop(key)<br>        elif self.remaining == 0:<br>            self.lru_cache.popitem(last=False)<br>        else:<br>            self.remaining -= 1<br>        self.lru_cache[key] = value<br><br><br>if __name__ == &quot;__main__&quot;:<br>    cache = LRU(3)<br>    print(cache.get(2))  # Expected: -1<br>    cache.add(2, 1)<br>    print(cache.get(2))  # Expected: 1<br>    cache.add(3, 1)<br>    cache.add(4, 2)<br>    cache.add(5, 3)<br>    cache.add(6, 4)<br>    print(cache.get(2))  # Expected: -1</pre><h4><strong>How It Works</strong></h4><ol><li><strong>Initialisation</strong>:</li></ol><ul><li>The cache is initialised with a fixed capacity.</li><li>We use an OrderedDict, which allows O(1) operations for adding, removing, and accessing elements.</li></ul><p>2. <strong>Get Operation</strong>:</p><ul><li>If the key exists in the cache, it is removed and reinserted to mark it as recently used.</li><li>If the key doesn’t exist, return -1.</li></ul><p>3. <strong>Add Operation</strong>:</p><ul><li>If the key already exists, remove it and update its value.</li><li>If the cache is full, remove the oldest (least recently used) item.</li><li>Add the new key-value pair.</li></ul><h4>Real-World Applications</h4><p>An LRU Cache is widely used in scenarios where quick access to frequently used data is required, such as:</p><ol><li><strong>Web Browsers</strong>:</li></ol><ul><li>Caching recently visited web pages.</li></ul><p><strong>2. Database Systems</strong>:</p><ul><li>Caching frequently accessed queries.</li></ul><p><strong>3. Operating Systems</strong>:</p><ul><li>Managing memory pages to optimize performance.</li></ul><h4>Thanks for reading.</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2979cda2a13" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/algorithm-challenge-lru-cache-a2979cda2a13">Algorithm Challenge: LRU Cache</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Polymorphism in Python]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/better-programming/exploring-polymorphism-in-python-f12b167c5e9f?source=rss-ee4a54b6bda3------2"><img src="https://cdn-images-1.medium.com/max/601/1*qYoWTcncdmYIx8GNQLVS8w.png" width="601"></a></p><p class="medium-feed-snippet">Understand how to apply polymorphism</p><p class="medium-feed-link"><a href="https://medium.com/better-programming/exploring-polymorphism-in-python-f12b167c5e9f?source=rss-ee4a54b6bda3------2">Continue reading on Better Programming »</a></p></div>]]></description>
            <link>https://medium.com/better-programming/exploring-polymorphism-in-python-f12b167c5e9f?source=rss-ee4a54b6bda3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f12b167c5e9f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Sarath Kaul]]></dc:creator>
            <pubDate>Tue, 31 Aug 2021 13:03:13 GMT</pubDate>
            <atom:updated>2021-08-31T13:03:13.512Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Interacting With Medium Using an API]]></title>
            <link>https://levelup.gitconnected.com/interacting-with-medium-using-an-api-524c41b2fd74?source=rss-ee4a54b6bda3------2</link>
            <guid isPermaLink="false">https://medium.com/p/524c41b2fd74</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ｍedium]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Sarath Kaul]]></dc:creator>
            <pubDate>Thu, 16 Apr 2020 12:43:26 GMT</pubDate>
            <atom:updated>2020-05-02T13:55:48.426Z</atom:updated>
            <content:encoded><![CDATA[<h4>Fetch your Medium feed using this Python script</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rHoZ-XzRKIYznOk9gOZ4xQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@iamjiroe?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jiroe</a> on <a href="https://unsplash.com/s/photos/api?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>An API is one of the ways in which we can interact with Medium and fetch data from it. In this article, we will be using an API and write a Python script revolving around it and enhancing its usage.</p><h3>Core of the Script</h3><p>We will be using an API that will serve as the main core of our application. So, our magical API is:</p><ul><li><a href="https://medium.com/feed/@kaul.sarath">https://medium.com/feed/&lt;USER_ID&gt;</a></li></ul><p>The main problem with this API is that it gives us the RSS feed which is a bit difficult to parse upon. Below is the RSS output of the API.</p><pre>Stories by Sarath Kaul on Medium Stories by Sarath Kaul on Medium <a href="https://medium.com/@kaul.sarath?source=rss-ee4a54b6bda3------2">https://medium.com/@kaul.sarath?source=rss-ee4a54b6bda3------2</a> <a href="https://cdn-images-1.medium.com/fit/c/150/150/0*46ZdJxIxnag7pMXj">https://cdn-images-1.medium.com/fit/c/150/150/0*46ZdJxIxnag7pMXj</a>. Stories by Sarath Kaul on Medium <a href="https://medium.com/@kaul.sarath?source=rss-ee4a54b6bda3------2">https://medium.com/@kaul.sarath?source=rss-ee4a54b6bda3------2</a> Medium Mon, 13 Apr 2020 14:37:52 GMT <a href="/service/mailto:yourfriends@medium.com">yourfriends@medium.com</a> Thanks Sarthak, Will be covering it in a separate story. <a href="https://medium.com/@kaul.sarath/thanks-sarthak-will-be-covering-it-in-a-separate-story-ce28096f41fe?source=rss-ee4a54b6bda3------2">https://medium.com/@kaul.sarath/thanks-sarthak-will-be-covering-it-in-a-separate-story-ce28096f41fe?source=rss-ee4a54b6bda3------2</a> <a href="https://medium.com/p/ce28096f41fe">https://medium.com/p/ce28096f41fe</a> Sarath Kaul Mon, 06 Apr 2020 02:58:58 GMT 2020-04-06T02:58:58.665Z &lt;p&gt;Thanks Sarthak, Will be covering it in a separate story.&lt;/p&gt;&lt;img src=&quot;<a href="https://medium.com/_/stat?event=post.clientViewed&amp;referrerSource=full_rss&amp;postId=ce28096f41fe">https://medium.com/_/stat?event=post.clientViewed&amp;referrerSource=full_rss&amp;postId=ce28096f41fe</a>&quot; width=&quot;1&quot; height=&quot;1&quot;&gt; Difference between Lists and Tuple &lt;div class=&quot;medium-feed-item&quot;&gt;&lt;p class=&quot;medium-feed-image&quot;&gt;&lt;a href=&quot;<a href="https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2">https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2</a>&quot;&gt;&lt;img src=&quot;<a href="https://cdn-images-1.medium.com/max/2600/1*gkncExgxa_rT8GYNHgSghg.jpeg">https://cdn-images-1.medium.com/max/2600/1*gkncExgxa_rT8GYNHgSghg.jpeg</a>&quot; width=&quot;5184&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;medium-feed-snippet&quot;&gt;Brief differences between two main pillars of data structures&lt;/p&gt;&lt;p class=&quot;medium-feed-link&quot;&gt;&lt;a href=&quot;<a href="https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2">https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2</a>&quot;&gt;Continue reading on codeburst »&lt;/a&gt;&lt;/p&gt;&lt;/div&gt; <a href="https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2">https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2</a> <a href="https://medium.com/p/9153fc329cd">https://medium.com/p/9153fc329cd</a> programming data-science python lists software-development Sarath Kaul Fri, 27 Mar 2020 14:33:35 GMT 2020-03-27T14:33:35.173Z Stop Using Python Decorators Redundantly &lt;div class=&quot;medium-feed-item&quot;&gt;&lt;p class=&quot;medium-feed-image&quot;&gt;&lt;a href=&quot;<a href="https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2">https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2</a>&quot;&gt;&lt;img src=&quot;<a href="https://cdn-images-1.medium.com/max/2600/1*wrII8wPx3atAf6KjQH36RQ.jpeg">https://cdn-images-1.medium.com/max/2600/1*wrII8wPx3atAf6KjQH36RQ.jpeg</a>&quot; width=&quot;6016&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;medium-feed-snippet&quot;&gt;How to set a decorator on every child class function from the parent class&lt;/p&gt;&lt;p class=&quot;medium-feed-link&quot;&gt;&lt;a href=&quot;<a href="https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2">https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2</a>&quot;&gt;Continue reading on Better Programming »&lt;/a&gt;&lt;/p&gt;&lt;/div&gt; <a href="https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2">https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2</a> <a href="https://medium.com/p/2f8467c9eeca">https://medium.com/p/2f8467c9eeca</a> data-science software-development python technology programming Sarath Kaul Wed, 04 Mar 2020 23:20:25 GMT 2020-03-04T23:20:25.740Z Public, Private, and Protected — Access Modifiers in Python &lt;div class=&quot;medium-feed-item&quot;&gt;&lt;p class=&quot;medium-feed-image&quot;&gt;&lt;a href=&quot;<a href="https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2">https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2</a>&quot;&gt;&lt;img src=&quot;<a href="https://cdn-images-1.medium.com/max/2600/1*oEpqSHbX0ZZXJqbJS-V2Rw.jpeg">https://cdn-images-1.medium.com/max/2600/1*oEpqSHbX0ZZXJqbJS-V2Rw.jpeg</a>&quot; width=&quot;5391&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;medium-feed-snippet&quot;&gt;A detailed view of how we can use access modifiers in Python&lt;/p&gt;&lt;p class=&quot;medium-feed-link&quot;&gt;&lt;a href=&quot;<a href="https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2">https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2</a>&quot;&gt;Continue reading on Better Programming »&lt;/a&gt;&lt;/p&gt;&lt;/div&gt; <a href="https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2">https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2</a> <a href="https://medium.com/p/9024f4c1dd4">https://medium.com/p/9024f4c1dd4</a> software-development python-programming data-science python programming Sarath Kaul Wed, 08 Jan 2020 16:38:53 GMT 2020-03-25T07:06:00.314Z Sending Bulk Emails With Python &lt;div class=&quot;medium-feed-item&quot;&gt;&lt;p class=&quot;medium-feed-image&quot;&gt;&lt;a href=&quot;<a href="https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2">https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2</a>&quot;&gt;&lt;img src=&quot;<a href="https://cdn-images-1.medium.com/max/688/1*mDE4PXx8N5nvmY25jTiI-A.png">https://cdn-images-1.medium.com/max/688/1*mDE4PXx8N5nvmY25jTiI-A.png</a>&quot; width=&quot;688&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;medium-feed-snippet&quot;&gt;An automated way to send out your emails&lt;/p&gt;&lt;p class=&quot;medium-feed-link&quot;&gt;&lt;a href=&quot;<a href="https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2">https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2</a>&quot;&gt;Continue reading on Level Up Coding »&lt;/a&gt;&lt;/p&gt;&lt;/div&gt; <a href="https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2">https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2</a> <a href="https://medium.com/p/4592b7ee57a5">https://medium.com/p/4592b7ee57a5</a> gmail email python programming data-science Sarath Kaul Fri, 18 Oct 2019 07:42:37 GMT 2020-02-29T15:33:16.626Z</pre><h3>Enhancing the Result of the API</h3><p>To enhance the result of our API, we will convert it into a JSON format which can be easily used with Python and for that, we will be using <a href="https://api.rss2json.com/v1/api.json">rss2json</a>.</p><p>This API is used to convert our RSS feed into JSON. So, we will be passing our Medium API as an RSS URL into this conversion API like below:</p><pre><a href="https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/@kaul.sarath">https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/@kaul.sarath</a></pre><p>It will return a JSON response like below:</p><pre>{&quot;status&quot;:&quot;ok&quot;,&quot;feed&quot;:{&quot;url&quot;:&quot;<a href="https://medium.com/feed/@kaul.sarath">https://medium.com/feed/@kaul.sarath</a>&quot;,&quot;title&quot;:&quot;Stories by Sarath Kaul on Medium&quot;,&quot;link&quot;:&quot;<a href="https://medium.com/@kaul.sarath?source=rss-ee4a54b6bda3------2">https://medium.com/@kaul.sarath?source=rss-ee4a54b6bda3------2</a>&quot;,&quot;author&quot;:&quot;&quot;,&quot;description&quot;:&quot;Stories by Sarath Kaul on Medium&quot;,&quot;image&quot;:&quot;<a href="https://cdn-images-1.medium.com/fit/c/150/150/0*46ZdJxIxnag7pMXj">https://cdn-images-1.medium.com/fit/c/150/150/0*46ZdJxIxnag7pMXj</a>.&quot;},&quot;items&quot;:[{&quot;title&quot;:&quot;Thanks Sarthak, Will be covering it in a separate story.&quot;,&quot;pubDate&quot;:&quot;2020-04-06 02:58:58&quot;,&quot;link&quot;:&quot;<a href="https://medium.com/@kaul.sarath/thanks-sarthak-will-be-covering-it-in-a-separate-story-ce28096f41fe?source=rss-ee4a54b6bda3------2">https://medium.com/@kaul.sarath/thanks-sarthak-will-be-covering-it-in-a-separate-story-ce28096f41fe?source=rss-ee4a54b6bda3------2</a>&quot;,&quot;guid&quot;:&quot;<a href="https://medium.com/p/ce28096f41fe">https://medium.com/p/ce28096f41fe</a>&quot;,&quot;author&quot;:&quot;Sarath Kaul&quot;,&quot;thumbnail&quot;:&quot;<a href="https://medium.com/_/stat?event=post.clientViewed&amp;referrerSource=full_rss&amp;postId=ce28096f41fe">https://medium.com/_/stat?event=post.clientViewed&amp;referrerSource=full_rss&amp;postId=ce28096f41fe</a>&quot;,&quot;description&quot;:&quot;\n&lt;p&gt;Thanks Sarthak, Will be covering it in a separate story.&lt;/p&gt;\n&lt;img src=\&quot;<a href="https://medium.com/_/stat?event=post.clientViewed&amp;amp;referrerSource=full_rss&amp;amp;postId=ce28096f41fe\">https://medium.com/_/stat?event=post.clientViewed&amp;amp;referrerSource=full_rss&amp;amp;postId=ce28096f41fe\</a>&quot; width=\&quot;1\&quot; height=\&quot;1\&quot;&gt;\n&quot;,&quot;content&quot;:&quot;\n&lt;p&gt;Thanks Sarthak, Will be covering it in a separate story.&lt;/p&gt;\n&lt;img src=\&quot;<a href="https://medium.com/_/stat?event=post.clientViewed&amp;amp;referrerSource=full_rss&amp;amp;postId=ce28096f41fe\">https://medium.com/_/stat?event=post.clientViewed&amp;amp;referrerSource=full_rss&amp;amp;postId=ce28096f41fe\</a>&quot; width=\&quot;1\&quot; height=\&quot;1\&quot;&gt;\n&quot;,&quot;enclosure&quot;:{},&quot;categories&quot;:[]},{&quot;title&quot;:&quot;Difference between Lists and Tuple&quot;,&quot;pubDate&quot;:&quot;2020-03-27 14:33:35&quot;,&quot;link&quot;:&quot;<a href="https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2">https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2</a>&quot;,&quot;guid&quot;:&quot;<a href="https://medium.com/p/9153fc329cd">https://medium.com/p/9153fc329cd</a>&quot;,&quot;author&quot;:&quot;Sarath Kaul&quot;,&quot;thumbnail&quot;:&quot;<a href="https://cdn-images-1.medium.com/max/2600/1*gkncExgxa_rT8GYNHgSghg.jpeg">https://cdn-images-1.medium.com/max/2600/1*gkncExgxa_rT8GYNHgSghg.jpeg</a>&quot;,&quot;description&quot;:&quot;&lt;div class=\&quot;medium-feed-item\&quot;&gt;\n&lt;p class=\&quot;medium-feed-image\&quot;&gt;&lt;a href=\&quot;<a href="https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2\">https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;&lt;img src=\&quot;<a href="https://cdn-images-1.medium.com/max/2600/1*gkncExgxa_rT8GYNHgSghg.jpeg/">https://cdn-images-1.medium.com/max/2600/1*gkncExgxa_rT8GYNHgSghg.jpeg\</a>&quot; width=\&quot;5184\&quot;&gt;&lt;/a&gt;&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-snippet\&quot;&gt;Brief differences between two main pillars of data structures&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-link\&quot;&gt;&lt;a href=\&quot;<a href="https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2\">https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;Continue reading on codeburst »&lt;/a&gt;&lt;/p&gt;\n&lt;/div&gt;&quot;,&quot;content&quot;:&quot;&lt;div class=\&quot;medium-feed-item\&quot;&gt;\n&lt;p class=\&quot;medium-feed-image\&quot;&gt;&lt;a href=\&quot;<a href="https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2\">https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;&lt;img src=\&quot;<a href="https://cdn-images-1.medium.com/max/2600/1*gkncExgxa_rT8GYNHgSghg.jpeg/">https://cdn-images-1.medium.com/max/2600/1*gkncExgxa_rT8GYNHgSghg.jpeg\</a>&quot; width=\&quot;5184\&quot;&gt;&lt;/a&gt;&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-snippet\&quot;&gt;Brief differences between two main pillars of data structures&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-link\&quot;&gt;&lt;a href=\&quot;<a href="https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2\">https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;Continue reading on codeburst »&lt;/a&gt;&lt;/p&gt;\n&lt;/div&gt;&quot;,&quot;enclosure&quot;:{},&quot;categories&quot;:[&quot;programming&quot;,&quot;data-science&quot;,&quot;python&quot;,&quot;lists&quot;,&quot;software-development&quot;]},{&quot;title&quot;:&quot;Stop Using Python Decorators Redundantly&quot;,&quot;pubDate&quot;:&quot;2020-03-04 23:20:25&quot;,&quot;link&quot;:&quot;<a href="https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2">https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2</a>&quot;,&quot;guid&quot;:&quot;<a href="https://medium.com/p/2f8467c9eeca">https://medium.com/p/2f8467c9eeca</a>&quot;,&quot;author&quot;:&quot;Sarath Kaul&quot;,&quot;thumbnail&quot;:&quot;<a href="https://cdn-images-1.medium.com/max/2600/1*wrII8wPx3atAf6KjQH36RQ.jpeg">https://cdn-images-1.medium.com/max/2600/1*wrII8wPx3atAf6KjQH36RQ.jpeg</a>&quot;,&quot;description&quot;:&quot;&lt;div class=\&quot;medium-feed-item\&quot;&gt;\n&lt;p class=\&quot;medium-feed-image\&quot;&gt;&lt;a href=\&quot;<a href="https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2\">https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;&lt;img src=\&quot;<a href="https://cdn-images-1.medium.com/max/2600/1*wrII8wPx3atAf6KjQH36RQ.jpeg/">https://cdn-images-1.medium.com/max/2600/1*wrII8wPx3atAf6KjQH36RQ.jpeg\</a>&quot; width=\&quot;6016\&quot;&gt;&lt;/a&gt;&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-snippet\&quot;&gt;How to set a decorator on every child class function from the parent class&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-link\&quot;&gt;&lt;a href=\&quot;<a href="https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2\">https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;Continue reading on Better Programming »&lt;/a&gt;&lt;/p&gt;\n&lt;/div&gt;&quot;,&quot;content&quot;:&quot;&lt;div class=\&quot;medium-feed-item\&quot;&gt;\n&lt;p class=\&quot;medium-feed-image\&quot;&gt;&lt;a href=\&quot;<a href="https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2\">https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;&lt;img src=\&quot;<a href="https://cdn-images-1.medium.com/max/2600/1*wrII8wPx3atAf6KjQH36RQ.jpeg/">https://cdn-images-1.medium.com/max/2600/1*wrII8wPx3atAf6KjQH36RQ.jpeg\</a>&quot; width=\&quot;6016\&quot;&gt;&lt;/a&gt;&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-snippet\&quot;&gt;How to set a decorator on every child class function from the parent class&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-link\&quot;&gt;&lt;a href=\&quot;<a href="https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2\">https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;Continue reading on Better Programming »&lt;/a&gt;&lt;/p&gt;\n&lt;/div&gt;&quot;,&quot;enclosure&quot;:{},&quot;categories&quot;:[&quot;data-science&quot;,&quot;software-development&quot;,&quot;python&quot;,&quot;technology&quot;,&quot;programming&quot;]},{&quot;title&quot;:&quot;Public, Private, and Protected — Access Modifiers in Python&quot;,&quot;pubDate&quot;:&quot;2020-01-08 16:38:53&quot;,&quot;link&quot;:&quot;<a href="https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2">https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2</a>&quot;,&quot;guid&quot;:&quot;<a href="https://medium.com/p/9024f4c1dd4">https://medium.com/p/9024f4c1dd4</a>&quot;,&quot;author&quot;:&quot;Sarath Kaul&quot;,&quot;thumbnail&quot;:&quot;<a href="https://cdn-images-1.medium.com/max/2600/1*oEpqSHbX0ZZXJqbJS-V2Rw.jpeg">https://cdn-images-1.medium.com/max/2600/1*oEpqSHbX0ZZXJqbJS-V2Rw.jpeg</a>&quot;,&quot;description&quot;:&quot;&lt;div class=\&quot;medium-feed-item\&quot;&gt;\n&lt;p class=\&quot;medium-feed-image\&quot;&gt;&lt;a href=\&quot;<a href="https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2\">https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;&lt;img src=\&quot;<a href="https://cdn-images-1.medium.com/max/2600/1*oEpqSHbX0ZZXJqbJS-V2Rw.jpeg/">https://cdn-images-1.medium.com/max/2600/1*oEpqSHbX0ZZXJqbJS-V2Rw.jpeg\</a>&quot; width=\&quot;5391\&quot;&gt;&lt;/a&gt;&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-snippet\&quot;&gt;A detailed view of how we can use access modifiers in Python&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-link\&quot;&gt;&lt;a href=\&quot;<a href="https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2\">https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;Continue reading on Better Programming »&lt;/a&gt;&lt;/p&gt;\n&lt;/div&gt;&quot;,&quot;content&quot;:&quot;&lt;div class=\&quot;medium-feed-item\&quot;&gt;\n&lt;p class=\&quot;medium-feed-image\&quot;&gt;&lt;a href=\&quot;<a href="https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2\">https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;&lt;img src=\&quot;<a href="https://cdn-images-1.medium.com/max/2600/1*oEpqSHbX0ZZXJqbJS-V2Rw.jpeg/">https://cdn-images-1.medium.com/max/2600/1*oEpqSHbX0ZZXJqbJS-V2Rw.jpeg\</a>&quot; width=\&quot;5391\&quot;&gt;&lt;/a&gt;&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-snippet\&quot;&gt;A detailed view of how we can use access modifiers in Python&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-link\&quot;&gt;&lt;a href=\&quot;<a href="https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2\">https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;Continue reading on Better Programming »&lt;/a&gt;&lt;/p&gt;\n&lt;/div&gt;&quot;,&quot;enclosure&quot;:{},&quot;categories&quot;:[&quot;software-development&quot;,&quot;python-programming&quot;,&quot;data-science&quot;,&quot;python&quot;,&quot;programming&quot;]},{&quot;title&quot;:&quot;Sending Bulk Emails With Python&quot;,&quot;pubDate&quot;:&quot;2019-10-18 07:42:37&quot;,&quot;link&quot;:&quot;<a href="https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2">https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2</a>&quot;,&quot;guid&quot;:&quot;<a href="https://medium.com/p/4592b7ee57a5">https://medium.com/p/4592b7ee57a5</a>&quot;,&quot;author&quot;:&quot;Sarath Kaul&quot;,&quot;thumbnail&quot;:&quot;<a href="https://cdn-images-1.medium.com/max/688/1*mDE4PXx8N5nvmY25jTiI-A.png">https://cdn-images-1.medium.com/max/688/1*mDE4PXx8N5nvmY25jTiI-A.png</a>&quot;,&quot;description&quot;:&quot;&lt;div class=\&quot;medium-feed-item\&quot;&gt;\n&lt;p class=\&quot;medium-feed-image\&quot;&gt;&lt;a href=\&quot;<a href="https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2\">https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;&lt;img src=\&quot;<a href="https://cdn-images-1.medium.com/max/688/1*mDE4PXx8N5nvmY25jTiI-A.png/">https://cdn-images-1.medium.com/max/688/1*mDE4PXx8N5nvmY25jTiI-A.png\</a>&quot; width=\&quot;688\&quot;&gt;&lt;/a&gt;&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-snippet\&quot;&gt;An automated way to send out your emails&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-link\&quot;&gt;&lt;a href=\&quot;<a href="https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2\">https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;Continue reading on Level Up Coding »&lt;/a&gt;&lt;/p&gt;\n&lt;/div&gt;&quot;,&quot;content&quot;:&quot;&lt;div class=\&quot;medium-feed-item\&quot;&gt;\n&lt;p class=\&quot;medium-feed-image\&quot;&gt;&lt;a href=\&quot;<a href="https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2\">https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;&lt;img src=\&quot;<a href="https://cdn-images-1.medium.com/max/688/1*mDE4PXx8N5nvmY25jTiI-A.png/">https://cdn-images-1.medium.com/max/688/1*mDE4PXx8N5nvmY25jTiI-A.png\</a>&quot; width=\&quot;688\&quot;&gt;&lt;/a&gt;&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-snippet\&quot;&gt;An automated way to send out your emails&lt;/p&gt;\n&lt;p class=\&quot;medium-feed-link\&quot;&gt;&lt;a href=\&quot;<a href="https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2\">https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2\</a>&quot;&gt;Continue reading on Level Up Coding »&lt;/a&gt;&lt;/p&gt;\n&lt;/div&gt;&quot;,&quot;enclosure&quot;:{},&quot;categories&quot;:[&quot;gmail&quot;,&quot;email&quot;,&quot;python&quot;,&quot;programming&quot;,&quot;data-science&quot;]}]}</pre><h3>Utilizing JSON</h3><p>We can now use this JSON for various purposes. For example, to fetch a story and response titles, categories, and much more. We will write such a Python script that will fetch titles of all our stories and responses.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c34b7980e385c2afb28900d98c686477/href">https://medium.com/media/c34b7980e385c2afb28900d98c686477/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*OnnZ4cB-8HsmLgKaaWK4iA.jpeg" /><figcaption>Output of Fetch Titles</figcaption></figure><p>You can replace MEDIUM_HANDLER with your handler and fetch the titles and change/improve them accordingly.</p><h3>Conclusion and Invitation</h3><p>I hope you liked this story. Do you think there is a better way to communicate with Medium?</p><p>You can find the source code repository for this API <a href="https://github.com/SKAUL05/medipy">on GitHub</a>. It is open to improvement. If anyone wants to contribute, you can fork and raise an Issue/PR. Hoping to see more contributors there!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=524c41b2fd74" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/interacting-with-medium-using-an-api-524c41b2fd74">Interacting With Medium Using an API</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Difference between Lists and Tuple]]></title>
            <link>https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd?source=rss-ee4a54b6bda3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9153fc329cd</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[lists]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Sarath Kaul]]></dc:creator>
            <pubDate>Fri, 27 Mar 2020 14:33:35 GMT</pubDate>
            <atom:updated>2020-03-27T14:33:35.173Z</atom:updated>
            <content:encoded><![CDATA[<p>Brief differences between two main pillars of data structures</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gkncExgxa_rT8GYNHgSghg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jentheodore?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jen Theodore</a> on <a href="https://unsplash.com/s/photos/lists?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Before jumping into the differences, let’s just start by the definitions of both the data structures.</p><p><strong><em>List</em></strong> is a type of data structure which allows collection of multiple data at same time. It is ordered and enables to store sequence of data.</p><pre>list_syntax = [&#39;I&#39;,&#39;Love&#39;,&#39;Python&#39;]</pre><p><strong><em>Tuples </em></strong>are sequences just like Lists, but is a sequence of immutable objects.</p><pre>tuple_syntax = (&#39;I&#39;,&#39;love&#39;,&#39;Python&#39;)</pre><p>Now let’s start by differences:</p><h4>1. Lists are mutable whereas Tuples are immutable</h4><p>This is one of the well known differences between the two data structures. It basically means that we can change lists but we can’t change tuples.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/047f660bc9e7dfe0d40be69014b9dbce/href">https://medium.com/media/047f660bc9e7dfe0d40be69014b9dbce/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*EpCarkAW5jj7wpiS1ti3Hg.jpeg" /><figcaption>Output to clarify the mutable and immutable nature</figcaption></figure><p>So according to above program, we cannot change tuples while we can change lists.</p><h4>2. Nature of Iterations</h4><p>Iterations are fairly faster in tuples compared to Lists. Let’s understand by example below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f19a5db574373093417f0d89baf5cb37/href">https://medium.com/media/f19a5db574373093417f0d89baf5cb37/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*6iSb4dKMyeOp-kQesEwv5Q.jpeg" /><figcaption>Output of Iterations over Lists and Tuple</figcaption></figure><p>The Output clearly suggests that time taken to iterate over tuples is lesser than Lists.</p><h4>3. Memory Consumption</h4><p>Lists consume a lot more memory compared to tuples.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8bb2e842f1b2997138d058a271a5f6e/href">https://medium.com/media/c8bb2e842f1b2997138d058a271a5f6e/href</a></iframe><p>The output of above program will show the memory consumption in both the data structures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*xJeuDrHMT7ITY0RJ9qHGbw.jpeg" /><figcaption>Output of Memory Consumption</figcaption></figure><h4>4. In Built Methods</h4><p>Lists are supported various built-in methods (append, insert, remove etc.) whereas in Tuples these methods are not available because you cannot modify tuples.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/249ccbe064731eb6f9cb4d77cc9a92cd/href">https://medium.com/media/249ccbe064731eb6f9cb4d77cc9a92cd/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*q8NbcJLfHHr94as3e2b-PA.jpeg" /><figcaption>Output of Built In Methods</figcaption></figure><h3>Conclusion</h3><p>I hope this explanation was useful. So should you use tuple or list ? The answer completely depends upon your use case.</p><p>Do you think one should always be preferred above another? Share your thoughts and experiences below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9153fc329cd" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/difference-between-lists-and-tuple-9153fc329cd">Difference between Lists and Tuple</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Using Python Decorators Redundantly]]></title>
            <link>https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca?source=rss-ee4a54b6bda3------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f8467c9eeca</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sarath Kaul]]></dc:creator>
            <pubDate>Wed, 04 Mar 2020 23:20:25 GMT</pubDate>
            <atom:updated>2020-03-04T23:20:25.740Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to set a decorator on every child class function from the parent class</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wrII8wPx3atAf6KjQH36RQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@kimberlyfarmer?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Kimberly Farmer</a> on <a href="https://unsplash.com/s/photos/class?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>The decorators are one of the powerful and useful tools in Python as they allow us to modify the behavior of a class or function. Decorators usually take a function as an argument and call it inside another function, which is usually known as a wrapper function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a74a3bb9a9bc14a31f86d2dd3a362db/href">https://medium.com/media/2a74a3bb9a9bc14a31f86d2dd3a362db/href</a></iframe><p>The above-defined input_args function is used to print the arguments and returns the output of the function called.</p><p>But what if we need to call on every function of a class, it could create a redundancy as mentioned in the below code snippet.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a9909813f5cfd73daf3392292e02d7b/href">https://medium.com/media/0a9909813f5cfd73daf3392292e02d7b/href</a></iframe><p>To avoid this redundancy, we could use another powerful tool provided to us by Python’s MetaClass. This MetaClass will help us to modify the function definitions of the child class which will reduce redundant calls to our decorator function.</p><p>Let’s look at how…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a06e11a5f2e0d6d223c174d88ab649c6/href">https://medium.com/media/a06e11a5f2e0d6d223c174d88ab649c6/href</a></iframe><p>Our Parent class will have the logic of setting our decorator to all the functions of a base class.</p><p>So, our final script would be something like the below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ea7e740898d45a57f75fa5ad0f61d13/href">https://medium.com/media/7ea7e740898d45a57f75fa5ad0f61d13/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*LlSCfvWuM3db8k2lLCC1yA.png" /><figcaption>The output of MetaClass usage</figcaption></figure><p>MetaClass Parent<strong> </strong>is now our weapon which can be inherited in any class where we want our decorator to be used.</p><h3>Conclusion</h3><p>I hope this explanation was useful. What are your thoughts on the usage of metaclass? Do you think there is another easier or better syntax? Share your thoughts and experiences below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f8467c9eeca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/stop-using-python-decorators-redundantly-2f8467c9eeca">Stop Using Python Decorators Redundantly</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Public, Private, and Protected — Access Modifiers in Python]]></title>
            <link>https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4?source=rss-ee4a54b6bda3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9024f4c1dd4</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sarath Kaul]]></dc:creator>
            <pubDate>Wed, 08 Jan 2020 16:38:53 GMT</pubDate>
            <atom:updated>2020-03-25T07:06:00.314Z</atom:updated>
            <content:encoded><![CDATA[<h3>Public, Private, and Protected — Access Modifiers in Python</h3><h4>A detailed view of how we can use access modifiers in Python</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oEpqSHbX0ZZXJqbJS-V2Rw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@dtopkin1?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Dayne Topkin</a> on <a href="https://unsplash.com/s/photos/private-public-protected?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Object-oriented languages, like C++ and Java, use various keywords to control and restrict the resource usage of a class.</p><p>This is where keywords like public, privateand protected come into the picture. However, Python has a different way of providing the functionality of these access modifiers.</p><h3>Public Keyword</h3><p>public members of a class are available to everyone. So they can be accessed from outside the class and also by other classes too.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83160c70cb21d5c524eb9927e97d41b8/href">https://medium.com/media/83160c70cb21d5c524eb9927e97d41b8/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9gJaPiyZQAuIBBnUhWzrAw.png" /><figcaption>Output of a public-access modifier</figcaption></figure><p>All members of a class are by default public in Python. These members can be accessed outside of the class, and their values can be modified too.</p><h3>Protected Keyword</h3><p>protected members of a class can be accessed by other members within the class and are also available to their subclasses.</p><p>No other entity can access these members. In order to do so, they can inherit the parent class. Python has a unique convention to make a member protected: Add a prefix <strong>_</strong> (single underscore).<em> </em>This prevents its usage by outside entities unless it is a subclass.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2154d85139422ccada70701994194f2/href">https://medium.com/media/c2154d85139422ccada70701994194f2/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*8zQVLpTENigNB4S23o7LBg.png" /><figcaption>Output of protected-access modifier</figcaption></figure><p>However, this doesn’t fully perform the functionality of the protected<strong> </strong>modifier. The attribute defined in the above program is accessible outside the class scope. It can also be modified as well.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6eb34bac86fc4449fc272c19f995821e/href">https://medium.com/media/6eb34bac86fc4449fc272c19f995821e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9gJaPiyZQAuIBBnUhWzrAw.png" /><figcaption>Output of protected attribute modified</figcaption></figure><h3>Private Keyword</h3><p>The private members of a class are only accessible within the class. In Python, a private member can be defined by using a prefix <strong>__ </strong>(double underscore).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca0791377e7d9ddba0e2bbb9c10663e1/href">https://medium.com/media/ca0791377e7d9ddba0e2bbb9c10663e1/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*frW-JyWeFzbrCWzsWeFGrw.png" /><figcaption>Output of private- access modifier</figcaption></figure><p>So, in the private modifier’s case, we cannot access the attribute. So is a private modifier the way ahead?</p><blockquote>The answer would be <strong><em>No</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*QYcs_hhoMIhA99Mmu_xumw.png" /></figure><p>Python performs name mangling on private attributes. Every member with a double underscore will be changed to _object._class__variable<em>.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cee7ed60bd6578c5139e8911d73e7ca/href">https://medium.com/media/4cee7ed60bd6578c5139e8911d73e7ca/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9gJaPiyZQAuIBBnUhWzrAw.png" /><figcaption>Output of private attribute modified</figcaption></figure><p>Therefore, this proves Python provides you with access-modifiers functionality, but it can’t be compared to classical languages like C++ and Java. This practice entirely depends upon the programmer.</p><p>So a responsible programmer, upon seeing an attribute with such a naming convention, would refrain from accessing it outside its scope. This also wouldn’t be good to use in cases where fellow programmers aren’t aware of such naming conventions.</p><p><em>Do you think that python should have the entire functionality of access modifiers like C++ &amp; Java? or Do you think it&#39;s not that important?</em><br><em>Leave your experiences and thoughts below!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9024f4c1dd4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/public-private-and-protected-access-modifiers-in-python-9024f4c1dd4">Public, Private, and Protected — Access Modifiers in Python</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sending Bulk Emails With Python]]></title>
            <link>https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5?source=rss-ee4a54b6bda3------2</link>
            <guid isPermaLink="false">https://medium.com/p/4592b7ee57a5</guid>
            <category><![CDATA[gmail]]></category>
            <category><![CDATA[email]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Sarath Kaul]]></dc:creator>
            <pubDate>Fri, 18 Oct 2019 07:42:37 GMT</pubDate>
            <atom:updated>2020-02-29T15:33:16.626Z</atom:updated>
            <content:encoded><![CDATA[<h4>An automated way to send out your emails</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*mDE4PXx8N5nvmY25jTiI-A.png" /></figure><p>Sending emails manually is a tedious, time-consuming, and error-prone task. We can automate this process using Python.</p><h3><strong>Getting Started</strong></h3><p>Python comes with various inbuilt modules. One that we can use for sending mails is <a href="https://docs.python.org/3/library/smtplib.html"><em>smptlib</em></a>,<em> </em>which uses the Simple Mail Transfer Protocol (<a href="https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol">SMTP</a>). The code that we write will use the Gmail SMTP server to send emails using Port <strong>587</strong> or <strong>465</strong>.</p><h3><strong>Sending Plain-Text Emails</strong></h3><p>We will start by importing all the helper modules that are required to send out emails.</p><p>We will use <a href="https://docs.python.org/2/library/email.mime.html"><em>email.mime</em></a> to structure our email message.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c13acc736134d194c616b7ed01b5ee6c/href">https://medium.com/media/c13acc736134d194c616b7ed01b5ee6c/href</a></iframe><p>We need to specify the email account and its credentials, which will be used to send out emails.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5910323a4f015a9406055c686beb098f/href">https://medium.com/media/5910323a4f015a9406055c686beb098f/href</a></iframe><p>Now, the core part will include the list of receiving emails and various headers of our email, like <em>Subject</em>, <em>Body</em>.</p><p>In this case, we will send a simple text message.</p><pre># list of users to whom email is to be sent<br>email_send = [&#39;LIST_OF_RECIPIENTS&#39;]</pre><pre>subject = &#39;EMAIL_SUBJECT&#39;</pre><pre>msg = MIMEMultipart()<br>msg[&#39;From&#39;] = email_user</pre><pre># converting list of recipients into comma separated string<br>msg[&#39;To&#39;] = &quot;, &quot;.join(email_send)</pre><pre>msg[&#39;Subject&#39;] = subject</pre><pre>body = &#39;EMAIL_BODY&#39;<br>msg.attach(MIMEText(body,&#39;plain&#39;))</pre><pre>text = msg.as_string()<br>server = smtplib.SMTP(&#39;smtp.gmail.com&#39;,587)<br>server.starttls()<br>server.login(email_user,email_password)<br>server.sendmail(email_user,email_send,text)<br>server.quit()</pre><p>The above code can be integrated with any front-end screen to receive LIST_OF_RECIPIENTS dynamically to send bulk emails at once.</p><h3>Sending Emails With HTML Content</h3><p>There isn’t a lot of change when sending out Emails with HTML content. We just need to tweak our Email Body a little, which will now contain text in the form of HTML.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/257f3c875ee935c1bde91a44fd63abb5/href">https://medium.com/media/257f3c875ee935c1bde91a44fd63abb5/href</a></iframe><p>So we changed our body text to one containing HTML, and MIMEText containing our body will refer it to as html instead of plain.</p><p>You can also use the above-described approach to send out emails containing attachments.</p><h3>More Information/Documentation</h3><ul><li><a href="https://docs.python.org/3/library/email.examples.html">Python Documentation</a></li><li><a href="https://realpython.com/python-send-email/">Real Python Article</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4592b7ee57a5" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/sending-bulk-emails-via-python-4592b7ee57a5">Sending Bulk Emails With Python</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>