I don't see the need of `if os.name == 'nt':` here if what are in the 2 cases are ~ same for the first block.