how to get the path of a module (myself) ?
Juergen.Hermann at 1und1.de
Mon Jun 15 11:33:58 EDT 2009
Stef Mientki <stef.mientki <at> gmail.com> 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/__init__.py <==
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