MRAB:
> from collections import defaultdict
> match_counter = defaultdict(int)
> for line in fileinput.input(sys.argv[1:]):
>      ip = line.split()[0]
>      match_counter[ip] += 1

This can be a little faster still:

match_counter = defaultdict(int)
for line in fileinput.input(sys.argv[1:]):
    ip = line.split(None, 1)[0]
    match_counter[ip] += 1

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to