Also, do y’all call main() in the if block or do you just put the code you want to run in the if block?

  • qx128@lemmy.world
    link
    fedilink
    arrow-up
    9
    arrow-down
    1
    ·
    1 month ago

    Nothing prevents you from putting a call to “main()” in the global scope

    • jacksilver@lemmy.world
      link
      fedilink
      arrow-up
      14
      ·
      1 month ago

      The point of the name==main logic is that it checks if that is the file that was invoked (like running python filename.py). If you just put a main() in the global scope it will be called either when the file is invoked or loaded (which can cause unintended consequences).

      • bastion@feddit.nl
        link
        fedilink
        arrow-up
        1
        ·
        1 month ago

        Due to the oneness of all things, I refuse to distinguish between library code and executable code. One and Zero are arbitrary limitations.