Malfunction in understanding the control flow in the python class (in the Google engine)

Guys, I am having trouble understanding the control flow in a python class, i.e. what happens with the code step by step. Given the short code below, I would like to know: when the MainPage class is called, does it just execute everything that is inside this class? In linear order? (first line, after the second, etc.)

enter image description here

+5
source share
2 answers

When a Python file is executed, each statement in the file is executed from top to bottom. In your case, there are six statements:

from ..
from ..
class MainPage ..
application = ..
def main() ..
if __name__ ..

Python , , , , , . , webapp run_wsgi_app.

MainPage. , , : a def. , def , . , .

webapp.WSGIApplication application.

main.

__name__. , Python, __name__. , , , Python, __name__ "__main__". if , : " - ?" , if.

if main(), run_wsgi_app, application.

WSGI, ", - URL-, URL- - , ". URL, "/" MainPage. - /URL, MainPage, .

, HTTP, /, GET, WSGI .get() MainPage. get , . , . WSGI -!

, WSGI URL. , , Python , .

+6

.

, (get). MainPage.

, , . , , application = .... , webapp MainPage, URL /. , . , main.

: main(). : application. run_wsgi_app , URL- , , , get() . , , .

, main .

: main, run_wsgi_app, MainPage get(), application.

+1

All Articles