error using mailbox

David Bear david.bear at asu.edu
Wed May 22 01:14:41 EDT 2002


Have python 2.1 installed on caldera open linux -- python 1.5 is also 
installed but all my symlink point to 2.1.  I'm attempting to using the 
mailbox module and am getting the following:

Traceback (most recent call last):
  File "./unixmail.py", line 8, in ?
    msg = mb.next()
  File "/usr/local/lib/python2.1/mailbox.py", line 19, in next
    self.fp.seek(self.seekp)
AttributeError: seek

my code is straight from the psl 2.0 book by oreilly..

#!/usr/local/bin/python
# psl2.0 p 156
import mailbox

mb = mailbox.UnixMailbox("syslog/npcenter")

while 1:
        msg = mb.next()
        if not msg:
                break
        for k, v in msg.items():
                print k, "=", v
        body = msg.fp.read()
        print body

Aside from the book is wrong, mailbox takes a file name rather than a file 
object, the code is exact.  Any reason I'm getting the attribute error?

-- 
David Bear
College of Public Programs/ASU
480-965-8257
...the way is like water, going where nobody wants it to go



More information about the Python-list mailing list