import traceback


class MyClass(object):

    def __init__(self):
        self.traceback = traceback.extract_stack()[-2]
obj = MyClass()
print('Instantiated in {0}:{1}'.format(*obj.traceback))
How can I find out where an object has been instantiated?