how to get the name of an object in python 1

how to get the name of an object in python

dict([(t.__name__, t) for t in fun_list])

Here is what the above code is Doing:
1. We’re creating a dictionary called fun_dict.
2. We’re using a list comprehension to create a list of tuples.
3. Each tuple is a key-value pair. The key is the name of the function, and the value is the function itself.
4. We’re passing the list of tuples to the dict() function, which creates a dictionary from the list.

Similar Posts