<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>python &amp;mdash; Joey Manani: The Blog</title>
    <link>https://blog.joeymanani.com/tag:python</link>
    <description>It&#39;s me, your host Joey, and this is an insight into my life and the stuff I get up to</description>
    <pubDate>Thu, 30 Apr 2026 15:16:48 +0000</pubDate>
    <item>
      <title>How to Install Python and VSCode on Windows</title>
      <link>https://blog.joeymanani.com/how-to-install-python-and-vscode-on-windows</link>
      <description>&lt;![CDATA[Want to get started with Python programming? Here’s a quick, step-by-step guide to installing Python and Visual Studio Code (VSCode) on Windows. &#xA;&#xA;div class=&#34;video-container&#34;&#xA;iframe src=&#34;https://www.youtube.com/embed/4uWb6Bo-9fw?si=6JpZW04VCEAyX6Vx&#34; frameborder=&#34;0&#34; allow=&#34;accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; allowfullscreen/iframe&#xA;/div&#xA;&#xA;!--more--&#xA;&#xA;Step 1: Download and Install Python&#xA;&#xA;1. Download Python&#xA;Head to the official Python download page.&#xA;You should see a big yellow button labeled &#34;Download Python 3.x.x&#34; (the latest version number). Click it to start the download.&#xA;&#xA;    Python Download Page&#xA;&#xA;2. Install Python&#xA;Open the downloaded installer file.&#xA;Important: Check the box that says &#34;Add Python to PATH&#34;. This makes running Python from the command line easier.&#xA;Choose Install Now and let the installer run.&#xA;Once the installation finishes, click Close.&#xA;&#xA;    Python Installer - Select &#34;Add to PATH&#34;&#xA;&#xA;3. Verify the Installation&#xA;To confirm Python is installed correctly:&#xA;Open Command Prompt (search “cmd” in the Start menu).&#xA;Type python --version and hit Enter.&#xA;    If installed correctly, you should see the Python version number displayed. &#xA;&#xA;    Python Successful Install&#34;&#xA;&#xA;Step 2: Download and Install Visual Studio Code (VSCode)&#xA;&#xA;1. Download VSCode&#xA;Go to the VSCode download page.&#xA;Choose the Windows option to start the download.&#xA;&#xA;    VSCode Download Page&#34;&#xA;&#xA;2. Install VSCode&#xA;Open the downloaded installer file.&#xA;Follow the on-screen instructions, and when you reach the setup screen, check the following boxes:&#xA;   Add &#34;Open with Code&#34; action to Windows Explorer (optional but useful).&#xA;   Add to PATH (recommended for terminal usage).&#xA;Continue with the installation, and when it’s complete, click Finish.&#xA;&#xA;    VSCode Installer Options&#34;&#xA;&#xA;Step 3: Set Up Python in VSCode&#xA;&#xA;1. Open VSCode and Install the Python Extension&#xA;Launch VSCode.&#xA;Go to the Extensions sidebar (click the four-square boxes icon or press Ctrl+Shift+X).&#xA;Search for Python and select the one by Microsoft.&#xA;Click Install to add the Python extension.&#xA;&#xA;    VSCode Download Page&#34;&#xA;&#xA;2. Verify Python Extension in a New File&#xA;Create a new file by clicking File   New File.&#xA;Save it as test.py.&#xA;Type a simple line of code like print(&#34;Hello, Python!&#34;) and save the file.&#xA;&#xA;    VSCode Python Example Script&#34;&#xA;&#xA;3. Run Python Code in VSCode&#xA;Right-click on the code and choose Run Python File in Terminal. This will open a terminal at the bottom of VSCode and execute the code.&#xA;    You should see Hello, Python! printed in the terminal.&#xA;&#xA;    VSCode Python in VSCode Success&#34;&#xA;&#xA;That&#39;s It!&#xA;&#xA;🎉 Congratulations! You now have Python and VSCode fully set up on your Windows computer!&#xA;&#xA;Keep coding, and check back for more guides to improve your development experience.&#xA;&#xA;Further Reading&#xA;&#xA;Why Catching All Exceptions is a Bad Idea in Python&#xA;&#xA;#blog #python #vscode #tutorial #programming #joeymanani&#xA;&#xA;---&#xA;Sidenote&#xA;&#xA;The application I used to simulate the screenshots was the Windows Sandbox - similar to a VM - and can be installed on your host machine in the builtin program Turn Windows features on or off inside of your start menu.&#xA;&#xA;I realised that I can use a href=&#34;https://tfrs.link/ffmpeg&#34; target=&#34;blank&#34;FFmpeg/a to convert PNG screenshots to a href=&#34;https://tfrs.link/webp&#34; target=&#34;blank&#34;WebP/a to compress them and optimize webpage load times. Pretty cool!&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Want to get started with Python programming? Here’s a quick, step-by-step guide to installing Python and Visual Studio Code (VSCode) on Windows.</p>

<div class="video-container">
<iframe src="https://www.youtube.com/embed/4uWb6Bo-9fw?si=6JpZW04VCEAyX6Vx" frameborder="0" allowfullscreen=""></iframe>
</div>



<h2 id="step-1-download-and-install-python">Step 1: Download and Install Python</h2>

<h3 id="1-download-python">1. Download Python</h3>
<ol><li>Head to the official <a href="https://www.python.org/downloads/">Python download page</a>.</li>

<li><p>You should see a big yellow button labeled “<strong>Download Python 3.x.x</strong>” (the latest version number). Click it to start the download.</p>

<p><img src="https://cdn.theflyingrat.com/images/blog/2024-11-08/python-page.webp" alt="Python Download Page"></p></li></ol>

<h3 id="2-install-python">2. Install Python</h3>
<ol><li>Open the downloaded installer file.</li>
<li><strong>Important</strong>: Check the box that says <strong>“Add Python to PATH”</strong>. This makes running Python from the command line easier.</li>
<li>Choose <strong>Install Now</strong> and let the installer run.</li>

<li><p>Once the installation finishes, click <strong>Close</strong>.</p>

<p><img src="https://cdn.theflyingrat.com/images/blog/2024-11-08/python-installer.webp" alt="Python Installer - Select &#34;Add to PATH&#34;"></p></li></ol>

<h3 id="3-verify-the-installation">3. Verify the Installation</h3>

<p>To confirm Python is installed correctly:
1. Open <strong>Command Prompt</strong> (search “cmd” in the Start menu).
2. Type <code>python --version</code> and hit Enter.
    – If installed correctly, you should see the Python version number displayed.</p>

<p>    <img src="https://cdn.theflyingrat.com/images/blog/2024-11-08/python-installation-successful.webp" alt="Python Successful Install&#34;"></p>

<h2 id="step-2-download-and-install-visual-studio-code-vscode">Step 2: Download and Install Visual Studio Code (VSCode)</h2>

<h3 id="1-download-vscode">1. Download VSCode</h3>
<ol><li>Go to the <a href="https://code.visualstudio.com/Download">VSCode download page</a>.</li>

<li><p>Choose the <strong>Windows</strong> option to start the download.</p>

<p><img src="https://cdn.theflyingrat.com/images/blog/2024-11-08/vscode-page.webp" alt="VSCode Download Page&#34;"></p></li></ol>

<h3 id="2-install-vscode">2. Install VSCode</h3>
<ol><li>Open the downloaded installer file.</li>
<li>Follow the on-screen instructions, and when you reach the setup screen, check the following boxes:
<ul><li><strong>Add “Open with Code” action to Windows Explorer</strong> (optional but useful).</li>
<li><strong>Add to PATH</strong> (recommended for terminal usage).</li></ul></li>

<li><p>Continue with the installation, and when it’s complete, click <strong>Finish</strong>.</p>

<p><img src="https://cdn.theflyingrat.com/images/blog/2024-11-08/vscode-installer.webp" alt="VSCode Installer Options&#34;"></p></li></ol>

<h2 id="step-3-set-up-python-in-vscode">Step 3: Set Up Python in VSCode</h2>

<h3 id="1-open-vscode-and-install-the-python-extension">1. Open VSCode and Install the Python Extension</h3>
<ol><li>Launch VSCode.</li>
<li>Go to the <strong>Extensions</strong> sidebar (click the four-square boxes icon or press <code>Ctrl+Shift+X</code>).</li>
<li>Search for <strong>Python</strong> and select the one by Microsoft.</li>

<li><p>Click <strong>Install</strong> to add the Python extension.</p>

<p><img src="https://cdn.theflyingrat.com/images/blog/2024-11-08/vscode-python.webp" alt="VSCode Download Page&#34;"></p></li></ol>

<h3 id="2-verify-python-extension-in-a-new-file">2. Verify Python Extension in a New File</h3>
<ol><li>Create a new file by clicking <strong>File &gt; New File</strong>.</li>
<li>Save it as <code>test.py</code>.</li>

<li><p>Type a simple line of code like <code>print(&#34;Hello, Python!&#34;)</code> and save the file.</p>

<p><img src="https://cdn.theflyingrat.com/images/blog/2024-11-08/vscode-python-script.webp" alt="VSCode Python Example Script&#34;"></p></li></ol>

<h3 id="3-run-python-code-in-vscode">3. Run Python Code in VSCode</h3>
<ol><li><p>Right-click on the code and choose <strong>Run Python File in Terminal</strong>. This will open a terminal at the bottom of VSCode and execute the code.</p>
<ul><li>You should see <code>Hello, Python!</code> printed in the terminal.</li></ul>

<p><img src="https://cdn.theflyingrat.com/images/blog/2024-11-08/vscode-python-success.webp" alt="VSCode Python in VSCode Success&#34;"></p></li></ol>

<h2 id="that-s-it">That&#39;s It!</h2>

<h4 id="congratulations-you-now-have-python-and-vscode-fully-set-up-on-your-windows-computer">🎉 Congratulations! You now have Python and VSCode fully set up on your Windows computer!</h4>

<p>Keep coding, and check back for more guides to improve your development experience.</p>

<h2 id="further-reading">Further Reading</h2>

<h4 id="why-catching-all-exceptions-is-a-bad-idea-in-python-https-blog-joeymanani-com-why-catching-all-exceptions-is-a-bad-idea-in-python"><a href="https://blog.joeymanani.com/why-catching-all-exceptions-is-a-bad-idea-in-python">Why Catching All Exceptions is a Bad Idea in Python</a></h4>

<p><a href="https://blog.joeymanani.com/tag:blog" class="hashtag"><span>#</span><span class="p-category">blog</span></a> <a href="https://blog.joeymanani.com/tag:python" class="hashtag"><span>#</span><span class="p-category">python</span></a> <a href="https://blog.joeymanani.com/tag:vscode" class="hashtag"><span>#</span><span class="p-category">vscode</span></a> <a href="https://blog.joeymanani.com/tag:tutorial" class="hashtag"><span>#</span><span class="p-category">tutorial</span></a> <a href="https://blog.joeymanani.com/tag:programming" class="hashtag"><span>#</span><span class="p-category">programming</span></a> <a href="https://blog.joeymanani.com/tag:joeymanani" class="hashtag"><span>#</span><span class="p-category">joeymanani</span></a></p>

<hr>

<h2 id="sidenote">Sidenote</h2>

<p>The application I used to simulate the screenshots was the <code>Windows Sandbox</code> – similar to a VM – and can be installed on your host machine in the builtin program <code>Turn Windows features on or off</code> inside of your start menu.</p>

<p>I realised that I can use <a href="https://tfrs.link/ffmpeg" target="_blank">FFmpeg</a> to convert PNG screenshots to <a href="https://tfrs.link/webp" target="_blank">WebP</a> to compress them and optimize webpage load times. Pretty cool!</p>
]]></content:encoded>
      <guid>https://blog.joeymanani.com/how-to-install-python-and-vscode-on-windows</guid>
      <pubDate>Fri, 08 Nov 2024 00:04:16 +0000</pubDate>
    </item>
    <item>
      <title>Why Catching All Exceptions is a Bad Idea in Python</title>
      <link>https://blog.joeymanani.com/why-catching-all-exceptions-is-a-bad-idea-in-python</link>
      <description>&lt;![CDATA[When you&#39;re writing Python code, you’ll often need to handle exceptions to ensure your program doesn&#39;t crash unexpectedly. However, catching all exceptions might seem like an easy fix, but it&#39;s actually a bad practice. Here&#39;s why.&#xA;&#xA;Example Python traceback&#xA;Example Python traceback | Joey Manani&#xA;!--more--&#xA;&#xA;1. The Risk of Masking Bugs&#xA;&#xA;One of the most dangerous aspects of catching all exceptions is that you may unintentionally hide bugs in your code. When you use a broad except clause like this:&#xA;&#xA;try:&#xA;    # some risky code that could produce many errors&#xA;except Exception:&#xA;    pass  # Catching all exceptions&#xA;&#xA;You’re ignoring the actual error, which essentially masks what went wrong. If you don’t see the error, how can you fix it? The issue may lie somewhere deeper in your logic, and by swallowing the exception, you&#39;re potentially missing valuable debugging clues as well as providing ambiguous feedback to users about what failed.&#xA;&#xA;2. Makes Debugging Harder&#xA;&#xA;By catching all exceptions, you&#39;re reducing the amount of information you can use to debug your program. In the worst case, a pretty vague except Exception could make you miss critical errors that would be more obvious if they weren’t caught. &#xA;&#xA;You need the ability to identify specific errors and address them in a targeted way. For example, catching specific exceptions such as ValueError, TypeError, or FileNotFoundError gives you better control and clearer insight into the problem.&#xA;&#xA;Example:&#xA;&#xA;Instead of this:&#xA;&#xA;try:&#xA;    # Open a file&#xA;except Exception:&#xA;    pass  # Ignoring all errors&#xA;&#xA;You should handle specific exceptions (yes, you can chain them!):&#xA;&#xA;try:&#xA;    # Open a file&#xA;except FileNotFoundError:&#xA;    print(&#34;The file doesn&#39;t exist!&#34;)&#xA;except IOError:&#xA;    print(&#34;There was an error opening the file!&#34;)&#xA;&#xA;Now, the program provides more useful feedback for when something goes wrong.&#xA;&#xA;3. A False Sense of Security&#xA;&#xA;Catching every exception may create a false sense of security, thinking that you’ve &#34;handled&#34; the errors, but that&#39;s not really the case. When you swallow exceptions, you don&#39;t know how the application behaves under real error conditions. Sometimes, what you&#39;re doing is delaying the problem rather than addressing it directly causing a headache down the line.&#xA;&#xA;Additionally, if the exception is silent, you may not notice issues until they snowball into something bigger, potentially causing bigger failures later.&#xA;&#xA;4. Best Practices for Handling Exceptions&#xA;&#xA;Instead of catching all exceptions, follow these practices:&#xA;&#xA;Catch Specific Exceptions: Always try to handle specific exceptions instead of using a generic except Exception. This gives you better control over the errors you expect.&#xA;&#xA;    Example:&#xA;&#xA;        try:&#xA;        result = 10 / 0&#xA;    except ZeroDivisionError:&#xA;        print(&#34;You can&#39;t divide by zero!&#34;)&#xA;    &#xA;Log the Exceptions: Even if you must catch all exceptions, ensure you log the error somewhere to help with debugging later.&#xA;&#xA;    Example:&#xA;&#xA;        import logging&#xA;&#xA;    try:&#xA;        # Risky code&#xA;    except Exception as e:&#xA;        logging.error(f&#34;An error occurred: {e}&#34;)&#xA;    &#xA;Use Finally for Cleanup: If you need to clean up resources (like closing a file), always use a finally block. This ensures cleanup happens whether or not an exception is raised.&#xA;&#xA;    Example:&#xA;&#xA;        try:&#xA;        # Risky code&#xA;    except ValueError:&#xA;        print(&#34;Oops, something went wrong!&#34;)&#xA;    finally:&#xA;        print(&#34;Cleanup done!&#34;)&#xA;    &#xA;Conclusion&#xA;&#xA;In summary, catching all exceptions is like applying a bandage to a broken leg— it&#39;s not the greatest of solutions, and it may cause more harm than good. By catching specific exceptions and handling them intelligently, you&#39;ll write more robust, debuggable code that enhances the user experience. &#xA;&#xA;#blog #python #programming #joeymanani]]&gt;</description>
      <content:encoded><![CDATA[<p>When you&#39;re writing Python code, you’ll often need to handle exceptions to ensure your program doesn&#39;t crash unexpectedly. However, catching <em>all</em> exceptions might seem like an easy fix, but it&#39;s actually a bad practice. Here&#39;s why.</p>

<p><img src="https://cdn.theflyingrat.com/images/blog/2024-07-11/traceback.webp" alt="Example Python traceback">
<em>Example Python traceback | Joey Manani</em>
</p>

<h2 id="1-the-risk-of-masking-bugs">1. The Risk of Masking Bugs</h2>

<p>One of the most dangerous aspects of catching all exceptions is that you may unintentionally hide bugs in your code. When you use a broad <code>except</code> clause like this:</p>

<pre><code class="language-python">try:
    # some risky code that could produce many errors
except Exception:
    pass  # Catching all exceptions
</code></pre>

<p>You’re ignoring the actual error, which essentially masks what went wrong. If you don’t see the error, how can you fix it? The issue may lie somewhere deeper in your logic, and by swallowing the exception, you&#39;re potentially missing valuable debugging clues as well as providing ambiguous feedback to users about what failed.</p>

<h2 id="2-makes-debugging-harder">2. Makes Debugging Harder</h2>

<p>By catching all exceptions, you&#39;re reducing the amount of information you can use to debug your program. In the worst case, a pretty vague <code>except Exception</code> could make you miss critical errors that would be more obvious if they weren’t caught.</p>

<p>You need the ability to identify specific errors and address them in a targeted way. For example, catching specific exceptions such as <code>ValueError</code>, <code>TypeError</code>, or <code>FileNotFoundError</code> gives you better control and clearer insight into the problem.</p>

<h3 id="example">Example:</h3>

<p>Instead of this:</p>

<pre><code class="language-python">try:
    # Open a file
except Exception:
    pass  # Ignoring all errors
</code></pre>

<p>You should handle specific exceptions (yes, you can chain them!):</p>

<pre><code class="language-python">try:
    # Open a file
except FileNotFoundError:
    print(&#34;The file doesn&#39;t exist!&#34;)
except IOError:
    print(&#34;There was an error opening the file!&#34;)
</code></pre>

<p>Now, the program provides more useful feedback for when something goes wrong.</p>

<h2 id="3-a-false-sense-of-security">3. A False Sense of Security</h2>

<p>Catching every exception may create a false sense of security, thinking that you’ve “handled” the errors, but that&#39;s not really the case. When you swallow exceptions, you don&#39;t know how the application behaves under real error conditions. Sometimes, what you&#39;re doing is delaying the problem rather than addressing it directly causing a headache down the line.</p>

<p>Additionally, if the exception is silent, you may not notice issues until they snowball into something bigger, potentially causing bigger failures later.</p>

<h2 id="4-best-practices-for-handling-exceptions">4. Best Practices for Handling Exceptions</h2>

<p>Instead of catching all exceptions, follow these practices:</p>
<ol><li><p><strong>Catch Specific Exceptions</strong>: Always try to handle specific exceptions instead of using a generic <code>except Exception</code>. This gives you better control over the errors you expect.</p>

<p>Example:</p>

<pre><code class="language-python">try:
    result = 10 / 0
except ZeroDivisionError:
    print(&#34;You can&#39;t divide by zero!&#34;)
</code></pre></li>

<li><p><strong>Log the Exceptions</strong>: Even if you must catch all exceptions, ensure you log the error somewhere to help with debugging later.</p>

<p>Example:</p>

<pre><code class="language-python">import logging

try:
    # Risky code
except Exception as e:
    logging.error(f&#34;An error occurred: {e}&#34;)
</code></pre></li>

<li><p><strong>Use Finally for Cleanup</strong>: If you need to clean up resources (like closing a file), always use a <code>finally</code> block. This ensures cleanup happens whether or not an exception is raised.</p>

<p>Example:</p>

<pre><code class="language-python">try:
    # Risky code
except ValueError:
    print(&#34;Oops, something went wrong!&#34;)
finally:
    print(&#34;Cleanup done!&#34;)
</code></pre></li></ol>

<h2 id="conclusion">Conclusion</h2>

<p>In summary, catching all exceptions is like applying a bandage to a broken leg— it&#39;s not the greatest of solutions, and it may cause more harm than good. By catching specific exceptions and handling them intelligently, you&#39;ll write more robust, debuggable code that enhances the user experience.</p>

<p><a href="https://blog.joeymanani.com/tag:blog" class="hashtag"><span>#</span><span class="p-category">blog</span></a> <a href="https://blog.joeymanani.com/tag:python" class="hashtag"><span>#</span><span class="p-category">python</span></a> <a href="https://blog.joeymanani.com/tag:programming" class="hashtag"><span>#</span><span class="p-category">programming</span></a> <a href="https://blog.joeymanani.com/tag:joeymanani" class="hashtag"><span>#</span><span class="p-category">joeymanani</span></a></p>
]]></content:encoded>
      <guid>https://blog.joeymanani.com/why-catching-all-exceptions-is-a-bad-idea-in-python</guid>
      <pubDate>Thu, 07 Nov 2024 05:00:00 +0000</pubDate>
    </item>
  </channel>
</rss>