pylint not recognizing some of the standard library

后端 未结 3 1573
逝去的感伤
逝去的感伤 2021-02-13 01:35

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 mo

3条回答
  •  失恋的感觉
    2021-02-13 02:28

    realise this is an old question, but the correct answer is that the older ways of invoking what you need, which use the "import hackery" that Richie describes, have long been deprecated (despite still appearing in many tutorials). If you use the new ways, you'll be writing better code and pylint won't complain.

    e.g.

    from email import Message
    from email import Header
    from email.MIMEText import MIMEText
    

    should be

    from email.message import Message
    from email.header import Header
    from email.mime.text import MIMEText
    

    etc.

提交回复
热议问题