Replace s.lstrip('file:') by re.sub(r'^file:', '', s).