Suppose I have a filename ./file
and I want to remove the leading ./
(if it starts with ./
). What would be the best python way to do this? My take at this is:
if filename.startswith("./"):
# remove leading ./
filename = filename[2:]
Isn't there a more elegant way?
PS: it should remove the leading part only if it matches exactly, think of the following filenames:
./filename
.configfile
../file
./.configfile