Let's say, I have a function named my_function and I'm passing an object as its parameter in the following way:
my_obj = MyClass()
my_function(my_obj)
Is there a way using which I can print the name of the function inside a method of MyClass?
Let's say that MyClass has a method called display_info inside it and it prints the name of the function in where the object of MyClass is passed.
An example would be:
class MyClass:
def print_log(self):
# some code
def random_method_1():
pass
def random_method_2():
def my_function(param1, some_name, some_number):
# some code
# Instantiating MyClass
my_object = MyClass()
# Calling my_function
my_function(my_object, "John Doe", 38478347)
my_object.print_log()
# Above line of code should be able to print "my_function"
my_function(my_obj)to result in "my_function" being printed? If so, why not just do that insidemy_function?