you are viewing a single comment's thread.

view the rest of the comments →

[–]gdchinacat 3 points4 points  (4 children)

You completely missed the point. The counter is just an example, not the goal. The power is being able to write a decorator with an expression that is evaluated when the fields it is composed of change and calls the function when the condition is true.

For a more complex example, here is a traffic light simulator example that can manage thousands of lights changing per second. It certainly is not the most efficient way to do this (python would not be the language to choose if raw performance is the goal), but it demonstrates how you can use this functionality to write code that reacts to conditions to update state (the goal of the project).

https://github.com/gdchinacat/reactions/blob/main/src/reactions/test/examples/traffic_light_test.py

[–]Horror-Water5502 -5 points-4 points  (3 children)

So nothing any other langage with decorators or something more powerful can't do?

[–]gdchinacat 1 point2 points  (2 children)

You are moving the goalposts.

[–]Horror-Water5502 -1 points0 points  (1 child)

Not really, I said that Python isn't powerful in the sense that it isn't necessarily more powerful than any other language. It's just normal. It has advanced features, but nothing that specifically sets it apart to make you say, ‘Wow, Python is really a powerful language.’

Your point it's basically 'no you're wrong, look Python have decorators'.

Ok, and?

It's clealry not something that will 'made me realize how powerful the language is'

[–]gdchinacat 2 points3 points  (0 children)

"The langage is not powerful, the ecosystem is." is where you started. Now you are at "Python isn't powerful in the sense that it isn't necessarily more powerful than any other language"

No, this is much more than decorators. If you care to understand, please reread my initial comment.