module name vs '.'

Neal Becker ndbecker2 at gmail.com
Mon Jun 18 09:47:46 EDT 2012


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 at 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 at think:~/temppython/src.directory$ python neal.py
> /mnt/data/davea/temppython/src.directory/becker.pyc
> Inside hello
> returning
> davea at think:~/temppython/src.directory$
>
> Observe the results of printing __file__
>
> Other approaches include putting a directory path containing a period
> into sys.path
>
>
>
> --
>
> DaveA
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120618/c5eb1498/attachment.html>


More information about the Python-list mailing list