title: pathlib mkdir creates a folder by filename
body: <p>I have the following preexisting folder in my machine</p>
  
  <pre><code>D:\scripts\myfolder
  </code></pre>
  
  <p>I want my script to create a folder named <code>logs</code> and create a file <code>log.txt</code> in it. So the path would look like</p>
  
  <pre><code>D:\scripts\myfolder\logs\somelog.txt
  </code></pre>
  
  <p>So I used</p>
  
  <pre><code>p = pathlib.Path("D:\scripts\myfolder\logs\somelog.txt")
  p.mkdir(parents=True, exisit_ok=True)
  </code></pre>
  
  <p>Now</p>
  
  <p><code>print(p.parents[0])</code> ==> <code>D:\scripts\myfolder\logs</code></p>
  
  <p><code>print(p.parents[1])</code> ==> <code>D:\scripts\myfolder</code></p>
  
  <p><code>print(p.parents[2])</code> ==> <code>D:\scripts</code></p>
  
  <p>So, as per <code>Path.mkdir</code> documentation
  <code>p.mkdir(parents=True, exisit_ok=True)</code> should create the folders <code>logs</code>, <code>myfolder</code> or <code>scripts</code> and so on if they don't exist. </p>
  
  <p>But it creates a folder by the name <code>some.txt</code> inside <code>logs</code> folder, although it is none of the <code>parents</code>. Why is that so?</p>
  
  <p>I understand that the workaround is to use <code>pathlib.Path("D:\scripts\myfolder\logs")</code></p>