Answer the question
In order to leave comments, you need to log in
How to normally write to flask in python 3.x?
Good
, I needed python, I had basic experience in java, I don’t understand a little how to write code normally, it works like that, but it’s some kind of dump. Those. I want methods and classes, but even a stupor I catch how to start writing them here, here is a screen
and where is the init class? Why start with "if" there is only one method, it's annotated to call get. I now need to get data from the database and wrap it in json and it turns out a sheet, I don’t even understand how to do methods / classes here, how to call? probably stupid, acclimatization, it’s just the second day I’m looking at what and how, in pure python I understand how with classes more or less, but here write where I want and everything works, but read horror
Answer the question
In order to leave comments, you need to log in
__init__.py perhaps? This is not a class. This is the initialization of the package. And what to write there - decide for yourself. Take a breath from the Procrustean bed of total java OOP :)))
"Starting with if" is very simple :) It's a way to determine that this script is called for execution, and not just imported by another script.
After Java to python, yes ... there will be breaking, but then you will like it. OOP in its purest form is needed only where it is needed. And where it’s easier without him, then he didn’t fall there :)))
In general, if you want to live easier, everything has already been invented everywhere. For example SQLAlchemy ;) And each framework has its own adaptation. And there are other ORMs.
Holy PEP-8 and Orthodox indentation do not allow writing "where I want". It will also break, but then it will screw in.
PS: I tried to see what you have in Java ... then I didn’t sleep for a week - I had nightmares.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question