A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

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