<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Path on Han's XYZ</title><link>https://han8931.github.io/tags/path/</link><description>Recent content in Path on Han's XYZ</description><generator>Hugo</generator><language>en</language><managingEditor>tabularasa8931@gmail.com (Han)</managingEditor><webMaster>tabularasa8931@gmail.com (Han)</webMaster><copyright>This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.</copyright><lastBuildDate>Mon, 15 Sep 2025 19:39:28 +0900</lastBuildDate><atom:link href="https://han8931.github.io/tags/path/index.xml" rel="self" type="application/rss+xml"/><item><title>Rediscovering Python's Pathlib</title><link>https://han8931.github.io/pathlib/</link><pubDate>Sat, 17 May 2025 00:00:00 +0000</pubDate><author>tabularasa8931@gmail.com (Han)</author><guid>https://han8931.github.io/pathlib/</guid><description>&lt;h2 id="from-type-hint-to-power-tool--pythons-pathlib"&gt;From Type Hint to Power Tool: Python&amp;rsquo;s &lt;code&gt;Pathlib&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;For a long time, I used &lt;code&gt;Path&lt;/code&gt; from Python&amp;rsquo;s &lt;code&gt;pathlib&lt;/code&gt; module purely as a &lt;strong&gt;type hint&lt;/strong&gt; - a way to make function signatures look more modern and semantically clear. Like this:&lt;/p&gt;
&lt;div class="code-block code-line-numbers open" style="counter-reset: code-block 0"&gt;
 &lt;div class="code-header language-python"&gt;
 &lt;span class="code-title"&gt;&lt;i class="arrow fas fa-angle-right fa-fw" aria-hidden="true"&gt;&lt;/i&gt;&lt;/span&gt;
 &lt;span class="ellipses"&gt;&lt;i class="fas fa-ellipsis-h fa-fw" aria-hidden="true"&gt;&lt;/i&gt;&lt;/span&gt;
 &lt;span class="copy" title="Copy to clipboard"&gt;&lt;i class="far fa-copy fa-fw" aria-hidden="true"&gt;&lt;/i&gt;&lt;/span&gt;
 &lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;pathlib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;process_file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file_path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;It changed when I started building an application that handled user-uploaded documents. I had to create temporary folders, write intermediate files, manage output paths, and ensure directories existed before saving results. That&amp;rsquo;s when &lt;code&gt;Path&lt;/code&gt; went from &lt;em&gt;just a type hint&lt;/em&gt; to a core part of my file management logic.&lt;/p&gt;</description></item></channel></rss>