Is there a module capable of doing this, or should I write something myself?
How about this:
>>> os.path.normpath("/bar/foo/baz/../..") "/bar"