views:

265

answers:

2

I'm using pylint + pydev, with python 2.6. I have a module with just this line of code

from email import Message

Now when I try to run this module it runs fine. But pylint reports an error:

ID: E0611 No name 'Message' in module 'email'

Although it exists... Any idea why?

+2  A: 

The email module uses some horrible import hackery, which has bitten me in the past. You can do this:

>>> from email import Message

but you can't do this:

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

I realise that's not very helpful for making pylint work, but it might help to explain the problem.

RichieHindle
what version you using? `email.Message` works for me on Debian using 2.5 and 2.6
Tshepang
+3  A: 

I like pylint, but I do find I have to use a lot of # pylint: disable-msg=E0611 and the like to make it shut up in cases that are perfectly correct but confuse it (for example, like in this case, due to email's playing with import tricks).

Alex Martelli