Skip to content

Instantly share code, notes, and snippets.

@thautwarm
Last active January 4, 2022 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thautwarm/902f73fb772284a59fc2f1401a974eb3 to your computer and use it in GitHub Desktop.
Save thautwarm/902f73fb772284a59fc2f1401a974eb3 to your computer and use it in GitHub Desktop.
from wisepy2 import wise
def main(filename: str):
"""return a pair:
- non-empty character count
- non-empty line count
"""
l = 0
c = 0
for line in open(filename, 'r', encoding='utf8'):
if not line.strip():
continue
l += 1
for ch in line:
if ch not in {'\n', '\r', ' ', '\t'}:
c += 1
print(c, l)
if __name__ == '__main__':
wise(main)()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment