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?

  • HiddenLayer555@lemmy.mlOP
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    2 days ago

    Luckily Python is one step ahead:

    Python 3.13.3 (main, Apr 22 2025, 00:00:00) [GCC 15.0.1 20250418 (Red Hat 15.0.1-0)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> if __name__ = "__main__":
    ... 
    ...    main()
    ...    
        File "<python-input-0>", line 1
        if __name__ = "__main__":
            ^^^^^^^^^^^^^^^^^^^^^
    SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
    

    Also TIL that := is a thing in Python.

    • iAvicenna@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      2 days ago

      yea I also couldnt get the formatting to work right, triple quotes kept turning things into accented letters, so I gave up.

      and also := also known as the walrus operator is very fun and sometimes very convenient to use