01: #! /usr/bin/python
02: 
03: import posix
04: from string import splitfields
05: 
06: def userinfo(filename):
07:   """
08:   This function returns the list of users
09:   and a table containing users and their passwords
10:   """
11:   users, table = [], {}
12:   file = open(filename, 'r')
13:   for line in file.readlines():
14:     [name, password] = splitfields(line, ':')[:2]
15:     users.append(name)
16:     table[name] = password
17:   return users, table
18: 
19: def main():
20:   for filename in ('/etc/passwd', 'etc/passwd.bak'):
21:     try:
22:       users, table = userinfo(filename)
23:       print table.keys()[3:7], table['postgres']
24:       posix.system('ls -al ' + filename)
25:     except:
26:       print 'File "' + filename + '" not found!'
27: 
28: main()
29: 
30: q.execute('''
31:     select * from
32:         foo,bar,baz
33:     where
34:         foo.blah=bar.blah
35:         and baz.spam="eggs"
36:     ''')
37: