M
M
mbcsoft2014-06-29 03:56:57
Python
mbcsoft, 2014-06-29 03:56:57

Python. How to study?

Hello. I want to start writing scripts in python, as I did in PHP. What is needed for this? At the moment I know primitive syntax, a couple of python functions. Installed a bunch of nginx + uwsgi + python3. Launched a simple hello world. Actually knowledge is very lacking, I want to choose a course. What books to read? Russian is desirable to be explained in detail.
In Php, everything is much simpler. I have index.php and do whatever I want there, but in python for a simple hello world you need to use
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')] )
return [b"Hello World"]
;)
Ok, the header is passed here. I understand that the web in python already works with a shell (like a framework), but I want to have more knowledge. And why does the server need to be restarted every time?

Answer the question

In order to leave comments, you need to log in

8 answer(s)
S
sim3x, 2014-06-29
@mbcsoft

And why does the server need to be restarted every time?

because it is compiling py -> pyc. For production, there is no need to change the code often. But for this case, uWSGI has a key.
In python, earlier than in PHP, dev servers appeared that allow you not to remember about this
try to run php script under uwsgi - you will see that it doesn't
this is a link for production. It lacks virtualenv + pip
On dev machines, everyone uses
# django
$ mkvirtualenv test-django
(test-django)$ pip install django
(test-django)$ django-admin startproject testdjango
(test-django)$ python manage.py runserver

# flash
$ mkvirtualenv test-flask
(test-flask)$ pip install Flask
(test-flask)$ echo 'from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()'>hello.py
(test-flask)$ python hello.py

# this approach is just coming into PHP About 13,200,000
results
https://www.google.com/search?q=python+tutorial

A
afiskon, 2014-06-29
@afiskon

Stupidly take the task and solve it. Google, look in books, ask on forums. After half a year, look at your code, go nuts and write again, this time it's better :) You can see the list of tasks here for example.

K
koriaf, 2014-06-29
@koriaf

If you are interested in web development, start right away with some framework, Django, for example. You can start learning from the documentation on her website, there are excellent examples.
If the language itself is interesting, then it is easier to run scripts directly from the console and experiment with the structure of the language, and only then deal with the web.
During my language learning days, Beginning Python - From Novice To Professional (2005) was a good book.

I
ixon, 2014-06-29
@ixon

Get a python and learn. Learn-learn learn-learn ras-ras-ras ras-ras-ras ras-ras-ras.

N
Nikita, 2014-07-25
@Freeddi

and with examples of programs (including on performance) is? otherwise Lutz has a dry theory, like documentation.

P
President42, 2014-10-23
@President42

In order not to fence what you had to fence, use Django (or some other web framework, there are many of them).
I would suggest doing this: learn the basics of Python first, without touching the web, and go to the basics of OOP in Python. After that, install Django and dig into it already.

K
kstyle, 2014-12-07
@kstyle

tasks can be taken here . and you need to pass the theory as part of the first year of the university - this is for any language in principle

V
Victor-Sproot, 2017-12-15
@Victor-Sproot

CoderNet
For example, here is enough literature to start

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question