Issue 25979: String functions lstrip are not working properly when you have escape sequence (original) (raw)
In this python code I am collecting list of folders present in the given location path with parent folder and print the folder names (output went wrong due to escape sequence values with lstrip.) Note : "\a \b \f \r \v \0 \1" are working fine. "\c \e \n \ne \t \te" went wrong.
Folder Structure : parent -> cat eat east next nest test
Wrong Output : Path: .\parent, List: ['cat', 'st', '', 'st', 'xt', 'st']
In this python code I am collecting list of folders present in the given location path with parent folder and print the folder names (output went wrong due to escape sequence values with lstrip.) Note : "\a \b \f \r \v \0 \1" are working fine. "\c \e \n \ne \t \te" went wrong.
Python Code : import glob as g
class Folders: def init(self, path, parent_folder_name): self.path = path + parent_folder_name + '\' self.parent_folder_name = parent_folder_name
def showFolders(self):
folders = [lst.lstrip(self.path) for lst in g.glob(self.path + '*')]
print('Path: '+self.path+ ', List: ',folders)
pass
if name == "main": obj = Folders(path='.\', parent_folder_name='parent') obj.showFolders()
Folder Structure : parent -> cat eat east next nest test
Wrong Output : Path: .\parent, List: ['cat', 'st', '', 'st', 'xt', 'st']