title: What is best to distinguish between file and dir path in a string
body: <p>I have the list of strings from the Amazon S3 API service which contain the full file path, like this:</p>
  
  <pre><code>fileA.jpg
  fileB.jpg
  images/
  </code></pre>
  
  <p>I want to put partition folders and files into different lists.</p>
  
  <p>How can I divide them?</p>
  
  <p>I was thinking of regex like this:</p>
  
  <pre><code>for path in list:
      if re.search("/$",path)
          dir_list.append(path)
      else
          file_list.append(path)
  </code></pre>
  
  <p>is there any better way?</p>