Re: Getting the name of the file that imported current module

2010-07-05 Thread kedra marbun
On Jul 5, 4:05 am, Tobiah wrote: > foo.py: > > import bar > bar.show_importer() > > output: > > 'foo' or 'foo.py' or 'path/to/foo' etc. > > Possible? > > Thanks, > > Tobiah if what you mean by 'importer' is the one that really cause py to load the mod, then why not dynamically set it? foo.py ---

Re: Getting the name of the file that imported current module

2010-07-05 Thread kedra marbun
On Jul 5, 6:29 am, Steven D'Aprano wrote: > On Sun, 04 Jul 2010 21:05:56 +, 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 >

Re: Getting the name of the file that imported current module

2010-07-04 Thread Mark Lawrence
On 05/07/2010 00:25, Michael Torrie wrote: On 07/04/2010 03:17 PM, Mark Lawrence wrote: On 04/07/2010 22:05, Tobiah wrote: foo.py: import bar bar.show_importer() output: 'foo' or 'foo.py' or 'path/to/foo' etc. Possible? Thanks, Tobiah >>> import re >>> re.__file__ 'C:\\Python26\\l

Re: Getting the name of the file that imported current module

2010-07-04 Thread Steven D'Aprano
On Sun, 04 Jul 2010 21:05:56 +, 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

Re: Getting the name of the file that imported current module

2010-07-04 Thread Michael Torrie
On 07/04/2010 03:17 PM, Mark Lawrence wrote: > On 04/07/2010 22:05, Tobiah wrote: >> foo.py: >> >> import bar >> bar.show_importer() >> >> output: >> >> 'foo' or 'foo.py' or 'path/to/foo' etc. >> >> Possible? >> >> Thanks, >> >> Tobiah > > >>> import re > >>> re.__file__ > 'C:\\Python26\\lib\\re

Re: Getting the name of the file that imported current module

2010-07-04 Thread Mark Lawrence
On 04/07/2010 22:05, Tobiah wrote: foo.py: import bar bar.show_importer() output: 'foo' or 'foo.py' or 'path/to/foo' etc. Possible? Thanks, Tobiah >>> import re >>> re.__file__ 'C:\\Python26\\lib\\re.pyc' HTH. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list

Getting the name of the file that imported current module

2010-07-04 Thread Tobiah
foo.py: import bar bar.show_importer() output: 'foo' or 'foo.py' or 'path/to/foo' etc. Possible? Thanks, Tobiah -- http://mail.python.org/mailman/listinfo/python-list