DISQUS

Asktav: Logrep: A Simple Apache Log Analysis Script

  • Marius Gedminas · 9 months ago
    Why didn't you use optparse or getopt but instead chose to implement command-line parsing manually?

    (Personally, I'm rather unhappy that 'pydoc optparse' doesn't have an example right there in the module docstring.)
  • tav · 9 months ago
    Hey Marius,

    Because the format I use with single-dash followed by word and arbitrary parameters is rather cumbersome to do with optparse..

    I do like optparse and have been using it since the days of Optik, so highly recommend it for any public facing projects.
  • tavis · 5 months ago
    don't work for me :
    [ps9392]$ python logrep.py access.log.2009-07-08 -what -total
    Traceback (most recent call last):
    File "logrep.py", line 27, in ?
    from collections import defaultdict
    ImportError: cannot import name defaultdict
  • tav · 5 months ago
    @tavis: defaultdict is part of Python 2.5 and later -- you'd need to use a more recent version of Python with logrep.py