Skip Navigation

Python needs an actual default function

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?

126

You're viewing a single thread.

126 comments
  • wait till you see

    if __name__ = "__main__":
    
       main()
    `
    • 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.

      • 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

126 comments