Python development services are still at the top of IT companies’ requests, although many believe that this is not the best choice. Next, we will debunk the main myth about this programming language and explain its popularity.
Quite often, Python is considered a language for beginners. It is taught at every turn, there are a million Python courses in the world. Top bloggers promise to teach him almost in one evening, they say that everyone immediately receives a serious salary, a comfortable office, and a happy future. Against this too rosy background, Python has firmly entrenched the image of a language for beginners, where it is enough to write a couple of for and def, declare a few variables – and now you are already a professional middle-level Python developer. And then you “outgrow” and go to write in a “serious language”.
In the language itself, we have a whole bunch of all sorts of knowledge, nuances, complexities, and declarative parts. Judge for yourself:
We have an iteration protocol. Of course, you can say that the iterator is not exactly part of functional programming, that other languages also have iterators. But I want to emphasize that iterators are not exactly easy, especially at the beginning, especially when we need to implement our own.
Decorators. Here you have higher-order functions, closures, and three levels of nesting for parameterized decorators – too much for such a “simple” language. At first, I myself did not understand the “decorator” pattern for a long time, I had difficulty writing them. And I know that many people have problems with this, it can be seen at least in interviews.
- Metaclasses. Classes creating classes? The type function, is it a class? And the type type is also type? All classes are created by type? Popular use case – ORM? Can I please have another “simple” language?
- Generators. You can ask in interviews: “What do you use generators for?” – and hear a lot of different answers. Some do not even understand why they are needed. But the generator supports the iteration protocol, you can send values to it, the yield from – well, you yourself understand everything.
- Dependency control. Venv, virtualenv, pipenv, poetry, pip tools, pdm, pipx, pyproject and so on.
- Infrastructure around Python. It would be extremely useful for work to know what pypa, pypi, psf are – and this is another separate layer of knowledge.
- P.E.P. Even experienced developers remember PEP8 at best.
- About a hundred magical methods. It would be nice to just navigate them.
- Powerful introspection and “meta-language” things. Runpy, importlib, trace, traceback, gc, inspect, sys, typing.get_type_hints, typing.get_origin, typing.get_args.
- Built-in error classes, methods, and types. You can run and get 156: import builtins; len(dir(builtins)). This is the number of built-in error classes, methods, and types. It is advisable to remember many of these.
- New things. Walrus operator, pattern matching.
- Competitive performance. Threading with a bunch of nuances, multiprocessing, subprocess, fresh communicating sequential processes “pattern” (PEP 554).
- Gil. Comments are not needed, but they will be (I don’t know how to succinctly, help).
- Special language options. Dict, list, set comprehensions, generator expressions, e.g.
- Asynchrony. This is a separate “subset” of the language, where there is already a whole universe of its own with a bunch of packages and even separate (not built into the language) concepts, like structured concurrency.
- Type annotations. Or annotated Python – also, consider your own mini-“subset” of the language, introducing a new conceptual apparatus, and a new type of typing – structural sub-typing, the closest analog of which from the world of dynamic typing could be called duck.
- Dynamic typing. Strict (sometimes “bypassed” by polyformism, or implicit casting of int to float), duck typing, typing. Protocol (about it above), gradual typing.