Programming-Idioms

History of Idiom 151 > diff from v10 to v11

Edit summary for version 11 :
New Python implementation by user [Oldboy]

Version 10

2017-07-29, 18:26:12

Version 11

2017-10-28, 13:33:02

Idiom #151 Remove string trailing path separator

Remove last character from string p, if this character is the file path separator of current platform.

Note that this also transforms unix root path "/" into empty string!

Idiom #151 Remove string trailing path separator

Remove last character from string p, if this character is the file path separator of current platform.

Note that this also transforms unix root path "/" into empty string!

Imports
import os
Code
if p.endswith(os.sep):
    p = p[:-1]