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
  • 33,213
  • 18
  • 87
  • 131

0 Answers0