Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 2
    Just to be clear, you want the final part without the extension? Commented Jun 15, 2018 at 13:44
  • Hint: look in module os.path Commented Jun 15, 2018 at 13:45
  • os.path.splitext(os.path.basename(a))[0] Commented Jun 15, 2018 at 13:46
  • 22
    Ignore all of those old answers for python 2.x on the question from 2009. Use pathlib. Commented Apr 12, 2019 at 19:53