Files
pytest2/_py/cmdline/pywhich.py
holger krekel 5791c06bf2 rewrote the initpkg mechanism and moved py lib implementation files to
_py/...  with py/__init__.py containing pointers into them

The new apipkg is only around 70 lines of code and allows
us to get rid of the infamous "py.__." by regular non-magical
"_py." imports. It is also available as a separately installable
package, see http://bitbucket.org/hpk42/apipkg

--HG--
branch : trunk
2009-10-03 01:47:39 +02:00

24 lines
490 B
Python
Executable File

#!/usr/bin/env python
"""\
py.which [name]
print the location of the given python module or package name
"""
import sys
def main():
name = sys.argv[1]
try:
mod = __import__(name)
except ImportError:
sys.stderr.write("could not import: " + name + "\n")
else:
try:
location = mod.__file__
except AttributeError:
sys.stderr.write("module (has no __file__): " + str(mod))
else:
print(location)