3

why does running the code below yields "Hello"?

class MyClass(object):
    print('Hello')

    def __init__(self):
        print('Hi')

In other words, why does python runs the code inside the class without it being instantiated? PS: I know that shouldn't be done, just trying to understand why it happens.

Diego
  • 34,802
  • 21
  • 91
  • 134

0 Answers0