CopyPastor

Detecting plagiarism made easy.

Score: 0.9031863980221025; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2018-09-15
by D Manokhin

Original Post

Original - Posted on 2015-10-10
by Martijn Pieters



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You opened the file in binary mode: with open(fname, 'rb') as f: This means that all data read from the file is returned as bytes objects, not str. You cannot then use a string in a containment test: if 'some-pattern' in tmp: continue You'd have to use a bytes object to test against tmp instead: if b'some-pattern' in tmp: continue or open the file as a textfile instead by replacing the `'rb'` mode with `'r'.`
You opened the file in binary mode:
with open(fname, 'rb') as f:
This means that all data read from the file is returned as `bytes` objects, not `str`. You cannot then use a string in a containment test:
if 'some-pattern' in tmp: continue
You'd have to use a `bytes` object to test against `tmp` instead:
if b'some-pattern' in tmp: continue
or open the file as a textfile instead by replacing the `'rb'` mode with `'r'`.

        
Present in both answers; Present only in the new answer; Present only in the old answer;