Showing content from http://mail.python.org/pipermail/python-dev/attachments/20150320/bf7cae78/attachment.html below:
<div dir="ltr">If ever someone wants to clean up the repository to conform to PEP 7, I wrote a program that catches a couple hundred PEP 7 violations in ./Python alone (1400 in the whole codebase):<div><br></div><div><div>import os</div><div>import re</div><div><br></div><div>def grep(path, regex):</div><div>  reg_obj = re.compile(regex, re.M)</div><div>  res = []</div><div>  for root, dirs, fnames in os.walk(path):</div><div>    for fname in fnames:</div><div>      if fname.endswith('.c'):</div><div>        path = os.path.join(root, fname)</div><div>        with open(path) as f:</div><div>          data = f.read()</div><div>          for m in reg_obj.finditer(data):</div><div>            line_number = sum(c == '\n'</div><div>                     for c in data[:m.start()]) + 1</div><div>            res.append("{}: {}".format(path, line_number))</div><div>  return res</div><div><br></div><div>for pattern in [</div><div>    r'^\s*\|\|',</div><div>    r'^\s*\&\&',</div><div>    r'} else {',</div><div>    r'\<return\s*\(',</div><div>]:</div><div>  print("Searching for", pattern)</div><div>  print("\n".join(grep('.', pattern)))</div></div><div><br></div><div>In my experience, it was hard to write PEP 7 conforming code when the surrounding code is inconsistent. </div><div><br></div><div>Best,</div><div><br></div><div>Neil</div></div>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4