We were recently debugging some code like this:

  re.compile('\\\\/')

This is legal Python (equivalent to r'\\/') but possibly buggy.  It would
be safer and clearer to say r'\\/' if that's what you want - and the 're'
manual highly recommends you should use raw strings here.

In Python (unlike C, Perl, Python REs and most unix tools) backslashes
followed by a non-special character in a string literal are passed through
as backslashes, which in my small survey surprised many people.

This patch gives a warning for string constants containing a backslash
followed by a character with no escaped meaning.  This seems like a good
way to catch strings that ought to be raw strings.

-- 
Martin

Attachment: 2012-08-31-pylint-backslashes-cleaned.diff
Description: Binary data

_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to