Entry 3807

Pyntch Original Example

   

Submitted by anonymous on May 12, 2010 at 12:24 a.m.
Language: Python. Code size: 276 bytes.

import sys, os

# Count the total number of characters for each file in directory.
def countchars(directory):
  n = 0
  for name in os.listdir(directory):
    fp = open(name)
    for line in fp:
      n += line
    fp.fclose()
  return n

countchars(sys.argv[1])

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).