To directly answer your question: __init__
is called as a consequence of calling Flask()
. Your original call is meant to initiate an instance of the class Flask
, and __init__
is the function that does the setup.
To solve your immediate problem though: You only need to pass one argument. The Error message is misleading.
It's not incorrect but it's talking about a function that's not the one you think you called. @codegeek 's example shows you what the "first" argument is. It's self
. But that's passed from inside the Class when class.__init__
is called as a consequence of calling Flask()
. You don't see self
being used, except for implicitly -- it's the (1 given) argument in your traceback, when you thought you were passing zero arguments.
Importantly, this isn't unique to this case -- you'll see the same thing in very simple examples like:
class Example:
def __init__(self, one):
self.one = one
ex = Example()
This will produce:
TypeError: __init__() takes exactly 2 arguments (1 given)
Meaning, Example()
calls __init__
which wants 'self' and 'one', and it only got 'self'.
(From the question though, I strongly recommend you read something like this http://pythoncentral.io/introduction-to-python-classes/ or another intro to python classes. Classes are a fundamental element of the language, and initializing them is a basic part of their functionality.)