• Captain Aggravated@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        3
        ·
        1 day ago

        AFAIK the syntax seems to be the same.

        def sayHam():
            print("Ham")
        
        sayHam()
        

        works when typed into the Python console, no class needed. I program as a hobby, I’m no expert on the language, but does Python even differentiate between functions and class methods internally? Other than just scope? There’s a possibility I’ll learn something today.

        • Uairhahs@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          23 hours ago

          Nope Def is universal for definition of a function wether it be a class method main method or even nested method