| CARVIEW |
Select Language
HTTP/2 200
server: nginx
date: Wed, 31 Dec 2025 02:38:55 GMT
content-type: text/html; charset=utf-8
expires: Wed, 31 Dec 2025 02:38:54 GMT
cache-control: no-cache
x-frame-options: sameorigin
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-permitted-cross-domain-policies: none
content-encoding: gzip
x-clacks-overhead: GNU Terry Pratchett
strict-transport-security: max-age=315360000; includeSubDomains; preload
Issue 25979: String functions lstrip are not working properly when you have escape sequence - Python tracker
- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
Issue25979
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2015-12-30 02:11 by Kiran Kotari, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg257223 - (view) | Author: Kiran Kotari (Kiran Kotari) | Date: 2015-12-30 02:11 | |
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']
|
|||
| msg257224 - (view) | Author: Kiran Kotari (Kiran Kotari) | Date: 2015-12-30 02:26 | |
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']
|
|||
| msg257225 - (view) | Author: Ethan Furman (ethan.furman) * ![]() |
Date: 2015-12-30 02:39 | |
lstrip() works by removing any of the characters in its argument, in any order; for example:
'catchy'.lstrip('cat')
# 'hy'
'actchy'.lstrip('tac')
# 'hy'
is stripping, from the left, all 'c's and all 'a's and all 't's -- not just the first three, and order does not matter.
The docs: https://docs.python.org/3/library/stdtypes.html?highlight=lstrip#str.lstrip
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:25 | admin | set | github: 70167 |
| 2015-12-30 02:39:09 | ethan.furman | set | status: open -> closed nosy: + ethan.furman messages: + msg257225 resolution: not a bug stage: resolved |
| 2015-12-30 02:26:36 | Kiran Kotari | set | messages: + msg257224 |
| 2015-12-30 02:25:53 | Kiran Kotari | set | files: - string_fun_error.py |
| 2015-12-30 02:11:39 | Kiran Kotari | create | |

