I don’t know if it’s the true place to ask, apologizing if not. I started to python one and half week ago. So I’m still beginner.

I made a terminal based weather application with python. What do you think about the code, is it good enough? I mean is it professional enough and how can I make the same functions with more less code?

Here’s the main file (I also added it as url to post): https://raw.githubusercontent.com/TheCitizenOne/openweather/refs/heads/main/openweather.py
Here’s the config.json file: https://raw.githubusercontent.com/TheCitizenOne/openweather/refs/heads/main/config.json

  • KindaABigDyl@programming.dev
    link
    fedilink
    arrow-up
    11
    ·
    2 days ago

    You appear to be afraid of spaces. Everything is cramped together.

    Just bc you don’t have to put a space after colons or after equals and commas and whatnot doesn’t mean you shouldn’t

    Don’t be afraid of spaces.

    They make it easier for you to read your code when you come back later

    • citizen@lemmy.worldOP
      link
      fedilink
      arrow-up
      1
      ·
      2 days ago

      I revised the code. Added some spaces and comments for better readability. Hope it’s better now.

      • FizzyOrange@programming.dev
        link
        fedilink
        arrow-up
        2
        ·
        1 day ago

        Instead you should just use an autoformatter. Black is good. Ruff is probably good too but I don’t have a lot of experience with it. YAPF is not good; don’t use it.

      • taaz@biglemmowski.win
        link
        fedilink
        English
        arrow-up
        7
        arrow-down
        1
        ·
        edit-2
        2 days ago

        Usually, you would use a formatter anyway - it’s good to know the standard way but for day to day coding I just have a shortcut bound that runs ruff format (you can even have it done automatically on file save).

      • Derp@lemmy.ml
        link
        fedilink
        arrow-up
        5
        ·
        2 days ago

        Not the original commenter, but no need to apologise my friend. Nice work. Learning tip from me: give PEP 8 a read and save it for reference somewhere. It’s the standard for how to format Python code, and future you will thank you for internalising it early on in your Python journey