If the filename has multiple dots, you can still use os.path.splitext() to split the filename into its base and extension parts: filename = 'example.test.txt' name_without_extension = os.path.splitext(os.path.splitext(filename)[0])[0]