Everytime I have to use some python script I fucking groan. God, what a pain in the ass python is...

  • captcha [any]
    ·
    2 years ago

    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.

      • yoink [she/her]
        ·
        edit-2
        2 years ago

        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

        • captcha [any]
          ·
          2 years ago

          Being able to externally mutate the internals of a function is bad and shouldn't be allowed in a language.

      • captcha [any]
        ·
        2 years ago

        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.

    • makotech222 [he/him]
      ·
      2 years ago

      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.