Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #61527

Re: python import error

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <torriem+gmail@torriefamily.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'subject:error': 0.03; 'tree': 0.05; 'importerror:': 0.07; 'namespace': 0.09; '__init__.py': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'helps.': 0.16; 'imports': 0.16; "john's": 0.16; 'namespace.': 0.16; 'subject:import': 0.16; 'think.': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'module': 0.19; 'normally': 0.19; 'import': 0.22; 'header:User-Agent:1': 0.23; 'either.': 0.24; 'package.': 0.24; 'file.': 0.24; 'right.': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'michael': 0.29; 'usually': 0.31; 'bunch': 0.31; 'file': 0.32; 'quite': 0.32; 'url:python': 0.33; '(most': 0.33; 'advice': 0.35; 'but': 0.35; "didn't": 0.36; 'url:org': 0.36; 'message-id:@gmail.com': 0.38; 'follows:': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'recent': 0.39; 'structure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'hope': 0.61; 'url:3': 0.61; "you'll": 0.62; 'email addr:gmail.com': 0.63; 'within': 0.65; 'inherent': 0.84
X-Virus-Scanned amavisd-new at torriefamily.org
Date Tue, 10 Dec 2013 22:02:34 -0700
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12
MIME-Version 1.0
To python-list@python.org
Subject Re: python import error
References <93405ea9-6faf-4a09-9fd9-ed264e3136e1@googlegroups.com> <52A7E94E.2010602@gmail.com>
In-Reply-To <52A7E94E.2010602@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3869.1386738181.18130.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386738181 news.xs4all.nl 2857 [2001:888:2000:d::a6]:32939
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61527

Show key headers only | View raw


On 12/10/2013 09:25 PM, Michael Torrie wrote:
> On 12/10/2013 08:56 PM, smilesonisamal@gmail.com wrote:
>> Traceback (most recent call last):
>>   File "aaa.py", line 5, in <module>
>>     from ccc.ddd import sss
>> ImportError: No module named ccc.ddd
>>
>> directory structure as follows:
>>
>> ccc
>> |
>>  ddd
>>    |
>>     aaa.py
>>     sss.py
> 
> This is because directories have no inherent meaning to python.  A
> module is normally a file.  If you want to group a bunch of files
> together you have to use a package. See the docs on how to make a
> package.  But the namespace structure within a package isn't based on
> the directory tree either.  It's usually set up by __init__.py within
> the package which imports modules defined in the package into the
> namespace.
> 
> http://docs.python.org/3/tutorial/modules.html#packages
> 
> Hope this helps.
> 

I didn't quite get that right.  Follow John's advice on __init.py__ and
you'll have what you want I think.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

python import error smilesonisamal@gmail.com - 2013-12-10 19:56 -0800
  Re: python import error Michael Torrie <torriem@gmail.com> - 2013-12-10 21:25 -0700
  Re: python import error John Gordon <gordon@panix.com> - 2013-12-11 04:53 +0000
    Re: python import error smilesonisamal@gmail.com - 2013-12-10 21:45 -0800
      Re: python import error Benjamin Kaplan <benjamin.kaplan@case.edu> - 2013-12-10 23:23 -0800
      Re: python import error Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-11 09:51 +0000
      Re: python import error John Gordon <gordon@panix.com> - 2013-12-11 16:15 +0000
  Re: python import error Michael Torrie <torriem@gmail.com> - 2013-12-10 22:02 -0700

csiph-web