def get_extension(path): dirsep = string.rfind(path, '/') dotsep = string.rfind(path, '.') if dotsep > dirsep: return path[dotsep + 1:] else: return ''