Re:Understanding Python through its builtins
by tored on Sunday October 10, 2021 @05:43PM
(#28822252)
As a non-Python dev I tried the other day to read up how decorators work in Python using the docs, can’t say it helped.
Re:Understanding Python through its builtins
by pansa2 on Sunday October 10, 2021 @07:44PM
(#28823000)
Decorators are very simple. I'm not surprised that there's not much documentation about them - there's just not much to say.
@decorator
def f(...): ...
is equivalent to: def f(...): ...
f = decorator(f)
That's it.
Re:Understanding Python through its builtins
by burnished on Monday October 11, 2021 @03:39PM
(#28832122)
If you read the docs then you basically would not know about them. My experience mirrors the people upthread. I also found that the Python community is very hostile to the idea that the docs might be insufficient, in that people suggesting this in threads were frequently belittled or it was often suggested that the questant should just learn it like they did, or that it wasn't really all that hard.
Re:Understanding Python through its builtins
by dehrmann on Monday October 11, 2021 @10:41PM
(#28835504)
I've looked at a lot of Javadocs and Python docs. Python's docs leave a lot more up to the imagination and are generally harder to navigate around.
Compare their ThreadPoolExecutors (Python's being inspired by Java's)
https://docs.python.org/3/library/concurrent.futures.html#co...
https://docs.oracle.com/javase/7/docs/api/java/util/concurre...
When I learned Kotlin, I just read through the docs, and then knew of basically all the different concepts in the language.
For Python, the docs were comparably very bad. For instance, Decorators aren't mentioned even once in the "The Python Tutorial". In "The Python Language Reference" (if one even bother to read such a dry document) it's barely mentioned in passing. How should a new user know it's a concept and how to apply it? And the language reference links only to a glossary item, and none of them specify how parameters in a decorator is supposed to work.
Pretty frustrating experience, put me a bit off the language from the get-go.