Guest User

Untitled

a guest
May 25th, 2012
288
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2.  
  3. # P2PU - Python Programming 101 - Chapter 10 - Regular Expressions
  4. # Python for Informatics - Chapter 11 - Regular Expressions
  5. # Exercise 11.2
  6.  
  7. import re
  8.  
  9. fname = 'mbox.txt'
  10. fhand = open(fname)
  11. revs = list()
  12.  
  13. for line in fhand:
  14.     line = line.rstrip()
  15.     rev = re.findall('^New Revision: (\d+)', line)
  16.     if len(rev) > 0:
  17.         revs.append(int(rev[0]))
  18.  
  19. print 'Average revision number: ', float(sum(revs))/len(revs)
RAW Paste Data