On Jul 5, 6:29 am, Steven D'Aprano <st...@remove-this- cybersource.com.au> wrote: > On Sun, 04 Jul 2010 21:05:56 +0000, Tobiah wrote: > > foo.py: > > > import bar > > bar.show_importer() > > > output: > > > 'foo' or 'foo.py' or 'path/to/foo' etc. > > > Possible? > > I don't think so. Your question isn't even well-defined. Given three > modules: > > # a.py > import b > import d > > # b.py > import d > > # c.py > import a > import d > import b > print d.show_importer() > > and you run c.py, what do you expect d.show_importer() to return? > > And what about "from d import show_importer" -- does that count as > "importing d"? > > Why do you think that a module needs to know what other modules imported > it? I can't imagine why this would be necessary, what are you intending > to do with it? > > -- > Steven
i guess he just likes to play things around, entertains his imagination, no need for practical reason for that -- http://mail.python.org/mailman/listinfo/python-list