[issue21283] A escape character is used when a REGEXP is an argument of strip string function

2014-04-21 Thread Tito Bouzout

Tito Bouzout added the comment:

Thanks guys for the information! Is still weird to me that the escape character 
is used, but well !  Will remember this bug. 
Kind regards,

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21283
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21283] A escape character is used when a REGEXP is an argument of strip string function

2014-04-17 Thread Tito Bouzout

New submission from Tito Bouzout:

Hello!

I got a report that the character \ was removed from a string using the 
following code

 \\server\path\to.strip(r'\'') 

At first insight, looks like a bug, because I don't expect the use of the 
escape character at all. Then I noticed, that our mistake there is that the 
strip argument should be a string not a REGEXP.

Kinda weird to read, and I've no idea if this is expected behaviour in Python, 
as I'm relatively very new. So just informing, 

Kind regards, 

-- 
Tito

--
components: Regular Expressions
messages: 216687
nosy: Tito.Bouzout, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: A escape character is used when a REGEXP is an argument of strip 
string function
type: behavior
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21283
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21283] A escape character is used when a REGEXP is an argument of strip string function

2014-04-17 Thread Matthew Barnett

Matthew Barnett added the comment:

The argument isn't a regex, it's a raw string literal consisting of the 
characters  (quote), \ (backslash), ' (apostrophe),  (less than) and  
(greater than).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21283
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21283] A escape character is used when a REGEXP is an argument of strip string function

2014-04-17 Thread Eric V. Smith

Eric V. Smith added the comment:

In addition, you probably want \\server\path\to to be a raw string, too. That 
way, the backslashes are not given special meaning. Notice the difference in 
output between these two:

 \\server\path\to.strip(r'\'') 
'server\\path\to'
 r\\server\path\to.strip(r'\'') 
'server\\path\\to'

In the first one, '\t' is being treated as a tab character, in the second one 
you see a backslash followed by a 't'.

My rule of thumb is: any time you have a string with a filename containing 
backslashes, you want it to be a raw string.

--
components:  -Regular Expressions
nosy: +eric.smith
resolution:  - not a bug
stage:  - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21283
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com