Module directory

Christian Tanzer tanzer at swing.co.at
Fri Sep 8 07:59:39 CEST 2000


"Gilles Lenfant" <glenfant at nospam-e-pack.net> wrote:

> I'm looking for a simple (and portable) way to get the path of the module
> from within a function it contains.

You have two options:

- Each python function has a `func_code' attribute which in turn
  provides a `co_filename' attribute.

- `imp.find_module' returns a three-element tuple -- the second
  element is the filename from which the module was loaded.

-- 
Christian Tanzer                                         tanzer at swing.co.at
Glasauergasse 32                                       Tel: +43 1 876 62 36
A-1130 Vienna, Austria                                 Fax: +43 1 877 66 92





More information about the Python-list mailing list