Logic for an init function in email parser I am writing an email parser and cannot decide how much logic should be included in the __init__ function. I know that a constructor should make the object ready for use, but are there best practices?

I've added several statements to my constructor:

def __init__(self, message):
    assert isinstance(message, basestring)

    parsed_message = email.message_from_string(message)

    if self._is_email(parsed_message):
        self.email_obj = parsed_message  
        email_payload = parsed_message.get_payload()
        self.valid_urls = self._find_valid_urls(email_payload)
        # ... some other stuff like looking for keywords etc.


What do you consider the most pythonic way:


Should I create a simple email object which possesses several methods that extract and return keywords, included URLs etc?
Do you consider it better to process all this information in the __init__ method and putting all results in object variables?
Notes:


Personally I prefer to keep the initialization method simple and lean. Just setup the minimum state of the object, let subsequent calls to methods do the real job when it's needed. Otherwise, why use a class? Maybe you don't need a class at all and just a function would do?
assert isinstance(message, basestring): Python is a dynamic language, embrace the fact and don't lose a second checking whether every argument has the type you expect (instead, write good docstrigs so the user knows how to call it). Another question is checking that given values satisfy some precondition (i.e assert len(s) &gt;= 10).