Developing a Package with Sub Packages

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Feb 18 15:02:36 EST 2008


En Mon, 18 Feb 2008 16:23:28 -0200, Josh English  
<joshua.r.english at gmail.com> escribi�:

> When testing the package in idle, this results in
> C:\Python25\Lib\idlelib
> instead of the file.
> The Data folder is created in this folder now.

Works for me:

main.py:
 from testpkg import a

testpkg directory (a subdirectory somewhere in sys.path):
testpkg\__init__.py:
(empty file)

testpkg\a.py:
import os
print __name__, __file__, os.path.abspath(os.path.dirname(__file__))

In IDLE: File -> Open, main.py. F5 (Run Module). Output:

testpkg.a C:\APPS\PYTHON25\lib\site-packages\testpkg\a.pyc
C:\APPS\PYTHON25\lib\site-packages\testpkg

-- 
Gabriel Genellina




More information about the Python-list mailing list