0

A class creates an object that prints out the method name when the object calls a function and prints out the runtime when the function is finished. For example:

class A(): # We can inherit any class we want
    age = 12
    price = 20
    def say(self):
        print("Hello World")

if __name__ == '__main__':
    a = A()
    a.say()
    a.age = 15

# The following should occur:
# 'A.some_method' is called                 # Print the name of method
# 'Hello World'                             # Function execution
# 'A.some_method' finished in 0.0000001ms.  # Print function execution time
# a.age = 15                                # Calls and assignments to general properties do not print any information

The same effect can be achieved when we call some built-in methods, such as __getattr__,__getattribute__,__dict__.

What should I do?Please help me,thanks everyone.

Pychong
  • 155
  • 2
  • 13

0 Answers0