Python is fine when used correctly. The problem is it's never used correctly. You're only ever supposed to use it to download data from some external source and process it. Or maybe write a one off script that has no dependencies. Webserver? GUI application? anything meant to scale? Orchestrating all your kubernetes jobs? Please stop.
The smartest thing Ansible did is replace what would be tomes of python code with a bunch of yaml. Even though its all python under the hood, people are writing less python and that's for the best.
literally this, as well as calling the function with every print instead of calling the variable they're after directly unless i'm missing something entirely
The point of my example is this shouldn't be possible. Local static variables shouldnt be publically available globally. (Local static variables shouldn't exist ever fwiw).
Python is one of those languages where you'll be fine as long as you never use 95% of its features.
Python is fine when used correctly. The problem is it's never used correctly. You're only ever supposed to use it to download data from some external source and process it. Or maybe write a one off script that has no dependencies. Webserver? GUI application? anything meant to scale? Orchestrating all your kubernetes jobs? Please stop.
The smartest thing Ansible did is replace what would be tomes of python code with a bunch of yaml. Even though its all python under the hood, people are writing less python and that's for the best.
def counter(): counter.value += 1 return counter.value counter.value = 0 print(counter()) # 1 print(counter()) # 2 print(counter()) # 3
Insane language.
I would simply not use a global :virgil-sad:
literally this, as well as calling the function with every print instead of calling the variable they're after directly unless i'm missing something entirely
Being able to externally mutate the internals of a function is bad and shouldn't be allowed in a language.
The point of my example is this shouldn't be possible. Local static variables shouldnt be publically available globally. (Local static variables shouldn't exist ever fwiw).
Python is one of those languages where you'll be fine as long as you never use 95% of its features.
If no one is ever using it correctly, then you can assert that the language guides you to make those bad choices. Its a bad language in that case.