Nando wrote: > > Sometimes, for things more or less like this, I just feel like > *subclassing* Message. But I can't. The MIME parser is wired to create > Messages. I don't think I can tell it to create a MyMessageSubclass. > This also happens with the convenience function > email.message_from_file(f). It creates a Message. I *think* I could make > it into a class method of Message, then I would be able to call > MyMessage.from_file(). Is this idea -- making things more > object-oriented -- interesting for you?
You can do this now, albeit somewhat differently. See the _class argument at <http://docs.python.org/lib/node149.html> and the _factory argument at <http://docs.python.org/lib/node148.html>. e.g. if your mymessage module defines a MyMessage class as a sub class of email.message.Message, you can do import email import mymessage f = open('/path/to/message/file') msg = email.message_from_file(f, mymessage.MyMessage) to create a MyMessage instance. You can also do import email import mymessage p = email.parser.Parser(mymessage.MyMessage) to create a parser which will create MyMessage instances. -- Mark Sapiro <[EMAIL PROTECTED]> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan _______________________________________________ Email-SIG mailing list Email-SIG@python.org Your options: http://mail.python.org/mailman/options/email-sig/archive%40mail-archive.com