Skip to content

Instantly share code, notes, and snippets.

@ackdav
Created April 14, 2017 10:37
Show Gist options
  • Save ackdav/3cd2c9f2287100401062e218424c2fe9 to your computer and use it in GitHub Desktop.
Save ackdav/3cd2c9f2287100401062e218424c2fe9 to your computer and use it in GitHub Desktop.
Fast way to get line count in python
def wccount(filename):
out = subprocess.Popen(['wc', '-l', filename],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
).communicate()[0]
return int(out.lstrip().split()[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment