how to get the path of a module (myself) ?
jh
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
Eeek.
> head -999 foo/*
==> foo/__init__.py <==
import pkg_resources
print pkg_resources.resource_string(__name__, "bar")
==> foo/bar <==
bar
> python -c "import foo"
bar
Make a "def load_resource" from that print line and you're done.
More information about the Python-list
mailing list