how to get the path of a module (myself) ?

jh Juergen.Hermann at
Mon Jun 15 11:33:58 EDT 2009

Stef Mientki <stef.mientki <at>> writes:
> I don't seem to have pkg_utils,
> only pkgutil, which doesn't have an apropiate function.
> But I found another way, don't know if that's reliable:
> import inspect
> print inspect.currentframe().f_code.co_filenameE


> head -999 foo/*
==> foo/ <==
import pkg_resources
print pkg_resources.resource_string(__name__, "bar")

==> foo/bar <==

> python -c "import foo"

Make a "def load_resource" from that print line and you're done.

More information about the Python-list mailing list