Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Simplify Unix Path by StefanPochmann
def simplify_path(path):
isabs = path.startswith('/')
parts = []
for part in path.split('/'):
if part not in '.':
if part == '..' and (isabs or (parts and parts[-1] != '..')):
del parts[-1:]
else:
parts.append(part)
return '/' * isabs + '/'.join(parts) or '.'
July 31, 2017
Comments: