remove extension from filename python

 import os
>>> base=os.path.basename('')
>>> base
>>> os.path.splitext(base)
('file', '.ext')
>>> os.path.splitext(base)[0]

Here is what the above code is Doing:
1. Importing the os module.
2. Creating a variable called base and setting it equal to the basename of the file.
3. Splitting the base variable into two parts, the filename and the extension.
4. Printing the filename.