On 06/18/2012 09:47 AM, Neal Becker wrote: > I meant a module > > src.directory contains > __init__.py > neal.py > becker.py > > from src.directory import neal > > > On Mon, Jun 18, 2012 at 9:44 AM, Dave Angel <d...@davea.name> wrote: > >> On 06/18/2012 09:19 AM, Neal Becker wrote: >>> Am I correct that a module could never come from a file path with a '.' >> in the >>> name? >>> >> >> No. >> >> Simple example: Create a directory called src.directory >> In that directory, create two files >> >> ::neal.py:: >> import becker >> print becker.__file__ >> print becker.hello() >> >> >> ::becker.py:: >> def hello(): >> print "Inside hello" >> return "returning" >> >> >> Then run neal.py, from that directory; >> >> >> davea@think:~/temppython/src.directory$ python neal.py >> /mnt/data/davea/temppython/src.directory/becker.pyc >> Inside hello >> returning >> davea@think:~/temppython/src.directory$ >> >> Observe the results of printing __file__ >> >> Other approaches include putting a directory path containing a period >> into sys.path >> >> >> >> -- >> >> DaveA >> >> >
In my example, becker.py is a module and I imported it. If you're now asking specifically about using the syntax from src.directory import neal that has nothing to do with periods being in a directory name. That period in the source code separates a package name from a module name, and will not find a package named "src.directory" -- DaveA -- http://mail.python.org/mailman/listinfo/python-list