Python function takes exactly 2 arguments (1 given)
python
Solution
You have to invoke the function through a View instance.
It's a common error in Django users don't instantiate class Views when writting url patterns. If you have the view "MyView" you must provide an instance MyView() to the url pattern.
If you have some class:
class SomeClass:
def some_function(self, foo): pass
you must call it like this:
some_instance = SomeClass()
some_instance.some_function(foo)
if you call it like this:
SomeClass.some_function(foo)
you don't have actually passed a object (self) as first param to some_function.
Problem
I am trying to parse gmail emails. From http://yuji.wordpress.com/2011/06/22/python-imaplib-imap-example-with-gmail/ I have the following: ``` def get_first_text_block(self, email_message_instance): maintype = email_message_instance.get_content_maintype() if maintype == 'multipart': for part in email_message_instance.get_payload(): if part.get_content_maintype() == 'text': return part.get_payload() elif maintype == 'text': return email_message_instance.get_payload() def hello(request): .... first = qs[0] one = first.get_email_object() print one['To'] out = get_first_text_block(one) ``` I'm getting: ``` get_first_text_block() takes exactly 2 arguments (1 given) ``` What am I doing wrong?