1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
import sys

fn = sys.argv[1]

if not fn:
  sys.exit(1)

hist = dict()
f = file(fn)
buf = f.read(1000)
while buf:
  for ch in buf:
    count = hist.get(ch, 0)
    count +=1
    hist.update({ch:count})
  buf = f.read(1000)
print hist