I still do not get why you need this.. does it not simply remove the trailing / from a path if there is one? If so, using path.rstrip(os.path.sep) is easier to read and to understand. Please also add a docstring if you decide to keep the method, to make it easier to understand.