Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python
referencing the module a piece of code is in
 

Index | Next | Previous | View Flat


hitt at eskimo

Sep 12, 2001, 11:31 AM


Views: 270
Permalink
referencing the module a piece of code is in

I'd like to be able to get a reference to a module a piece of
code is in.

I can do something like:
# my_module.py

class dummy:
pass

def my_module():
import sys
return sys.modules[dummy.__module__]

but this feels much too lengthy. I'd prefer something like

# my_desired_module.py

def my_module():
return __nifty_abbreviation_for_module__

Is this possible (and if not, why not?)?

Thanks in advance for any info (including references to the FAQ etc).

dan

Subject User Time
referencing the module a piece of code is in hitt at eskimo Sep 12, 2001, 11:31 AM
    referencing the module a piece of code is in shalehperry at home Sep 12, 2001, 11:50 AM
        referencing the module a piece of code is in hitt at eskimo Sep 12, 2001, 1:53 PM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.