I am trying to find the extension of a file, given its name as a string. I know I can use the function os.path.splitext but it does not work as expected in case
os.path.splitext
root,ext = os.path.splitext('a.tar.gz') if ext in ['.gz', '.bz2']: ext = os.path.splitext(root)[1] + ext
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.