Re: How to find out in which module an instance of a class is created?

2009-08-16 Thread Johannes Janssen
Chris Rebert schrieb: On Sun, Aug 16, 2009 at 6:25 AM, Johannes Janssen wrote: Gabriel Genellina schrieb: The try/except around sys._getframe(1) is because that function is not mandatory/available on all Python implementations (that's the case for jython which doesn't

Re: How to find out in which module an instance of a class is created?

2009-08-16 Thread Johannes Janssen
Gabriel Genellina schrieb: The try/except around sys._getframe(1) is because that function is not mandatory/available on all Python implementations (that's the case for jython which doesn't provide it). Thanks, shouldn't such information be part of the python documentation of sys._getframe()

Re: How to find out in which module an instance of a class is created?

2009-08-10 Thread Johannes Janssen
Christian Heimes schrieb: Johannes Janssen wrote: > class A(object): > def __init__(self, mod=__name__): > self.mod = mod won't work. In this case mod would always be "foo". You have to inspect the stack in order to get the module of the calle

How to find out in which module an instance of a class is created?

2009-08-09 Thread Johannes Janssen
Hi I like to know in which module an instance of a class was initialized. Using __module__ or __name__ within a class only gives me the module in which the class was defined not the instance of the class. Is there some (simple) way to do this? For better understanding I'll give an example how I