[issue34859] python core in string substring search

2018-10-01 Thread Ammar Askar
Ammar Askar added the comment: Please read this excerpt from the documentation Ronald linked for open: newline controls how universal newlines mode works (it only applies to text mode). It can be None, '', '\n', '\r', and '\r\n'. It works as follows: When reading input from the stream, if ne

[issue34859] python core in string substring search

2018-10-01 Thread pashkasan
pashkasan added the comment: str2 = open('sample.txt', 'rU').read() if "\n" in str2: print ("\\n found") else: print ("\\n not found") if "\r" in str2: print ("\\r found") else: print ("\\r not found") if "\r\n" in str2: print ("\\r\\n found") else:

[issue34859] python core in string substring search

2018-10-01 Thread Ronald Oussoren
Ronald Oussoren added the comment: @pahskazan: It is correct that '\r\n' is not found in those strings, Python source code is always parsed after conversion to "Unix" line endings with "\n" between lines. This is basicly the same as the "universal newlines" feature of the open function

[issue34859] python core in string substring search

2018-10-01 Thread pashkasan
pashkasan added the comment: >I suspect that there may also be confusion about the line ending in multiline >strings. Is there any documentation on the fact that this is always "\n" and >not "\r\n" (even on Windows)? the problem is that "\r\n" not found in source multiline strings str, str

[issue34859] python core in string substring search

2018-10-01 Thread Ronald Oussoren
Ronald Oussoren added the comment: I suspect that there may also be confusion about the line ending in multiline strings. Is there any documentation on the fact that this is always "\n" and not "\r\n" (even on Windows)? The closest I've found is the Lexical Analysis part of the language re

[issue34859] python core in string substring search

2018-10-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: The test code for the third case looks incorrect in two places: Given: if str.find("\n\r"): ^-- should compare to -1 - these are reversed Corrected: if str.fin

[issue34859] python core in string substring search

2018-10-01 Thread Ronald Oussoren
Ronald Oussoren added the comment: What do you think the problem is? The output of the script is what I'd expect it to be. Note that str.find() returns -1 when the needle is not present (and the first offset where the needle is found when it is present). -- nosy: +ronaldoussoren __

[issue34859] python core in string substring search

2018-09-30 Thread pashkasan
New submission from pashkasan : find substring in string its correct behavior? sample code str = """ Content-Length: 3192 Connection: close Cookie: _secure_admin_session_id=2a5dc26329de17ca4eafe; -1477319126846 Content-Disposition: form-data; name="utf8