email module documentation

D

David Bear

I'm confused about how to use the email module in python 2.4.x

I'm using python packaged with suse 9.3.

From the module documetation at http://docs.python.org/lib/node597.html I
found the following example (items cut):

import email

....
msg = email.message_from_file(fp)
...

Yet, when I try this I get the message

Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'message_from_file'

so I dir(email) reveals:

['__builtins__', '__doc__', '__file__', '__name__', 'cStringIO', 'email',
'getMessage', 'sys']

This is nothing like the documentation on python.org.

Any idea what I am missing?
 
R

Robert Kern

David said:
I'm confused about how to use the email module in python 2.4.x

I'm using python packaged with suse 9.3.
found the following example (items cut):

import email

...
msg = email.message_from_file(fp)
..

Yet, when I try this I get the message

Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'message_from_file'

so I dir(email) reveals:

['__builtins__', '__doc__', '__file__', '__name__', 'cStringIO', 'email',
'getMessage', 'sys']

This is nothing like the documentation on python.org.

Any idea what I am missing?

That's not what I have on OS X with Python 2.4.1.

In [1]: import email

In [2]: dir(email)
Out[2]:
['__all__',
'__builtins__',
'__doc__',
'__file__',
'__name__',
'__path__',
'__version__',
'message_from_file',
'message_from_string']

Are you sure that you're getting the right file? Check email.__file__ .

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
D

David Bear

Robert said:
David said:
I'm confused about how to use the email module in python 2.4.x

I'm using python packaged with suse 9.3.
found the following example (items cut):

import email

...
msg = email.message_from_file(fp)
..

Yet, when I try this I get the message

Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'message_from_file'

so I dir(email) reveals:

['__builtins__', '__doc__', '__file__', '__name__', 'cStringIO', 'email',
'getMessage', 'sys']

This is nothing like the documentation on python.org.

Any idea what I am missing?

That's not what I have on OS X with Python 2.4.1.

In [1]: import email

In [2]: dir(email)
Out[2]:
['__all__',
'__builtins__',
'__doc__',
'__file__',
'__name__',
'__path__',
'__version__',
'message_from_file',
'message_from_string']

Are you sure that you're getting the right file? Check email.__file__ .

never mind. I just discovered my error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top