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


Groups > comp.lang.python > #20923

Re: Question about circular imports

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'attribute': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'a.py': 0.16; 'c.py': 0.16; 'identifier': 0.16; 'subject:Question': 0.19; '(most': 0.21; 'traceback': 0.24; 'work.': 0.27; 'import': 0.27; 'tried': 0.27; 'does': 0.32; 'that,': 0.32; 'error.': 0.32; 'object': 0.33; 'file': 0.34; 'header:X-Complaints-To:1': 0.34; 'last):': 0.34; 'to:addr:python-list': 0.35; 'received:org': 0.36; 'run': 0.37; 'but': 0.37; 'skip:" 10': 0.37; 'to:addr:python.org': 0.40; 'follow': 0.61; 'choose': 0.64; 'frank': 0.64; 'received:41': 0.71
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From "Frank Millman" <frank@chagford.com>
Subject Re: Question about circular imports
Date Mon, 27 Feb 2012 08:16:47 +0200
References <jid2a9$n21$1@dough.gmane.org> <jid424$vfp$1@dough.gmane.org> <jieaid$e4k$1@dough.gmane.org>
X-Gmane-NNTP-Posting-Host 41-135-111-160.dsl.mweb.co.za
X-MSMail-Priority Normal
X-Newsreader Microsoft Outlook Express 6.00.3790.4657
X-RFC2646 Format=Flowed; Response
X-MimeOLE Produced By Microsoft MimeOLE V6.00.3790.4913
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.189.1330323422.3037.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1330323422 news.xs4all.nl 6869 [2001:888:2000:d::a6]:53618
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20923

Show key headers only | View raw


>
> To avoid the tedious reference, follow this with
> read = sound.formats.wavread # choose the identifier you prefer
>

@Terry and OKB

I tried that, but it does not work.

a.py
/b
    __init__.py
    c.py
   d.py

a.py -
    from b import c
c.py -
    import b.d
d.py -
    import b.c

If I run a.py, it returns with no error.

c.py -
    import b.d
    d = b.d
d.py -
    import b.c
    c = b.c

If I run a.py, I get

Traceback (most recent call last):
  File "F:\tests\a.py", line 1, in <module>
    from b import c
  File "F:\tests\b\c.py", line 1, in <module>
    import b.d
  File "F:\tests\b\d.py", line 2, in <module>
    c = b.c
AttributeError: 'module' object has no attribute 'c'

I get the same if I try 'import b.c as c'.

Frank


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


Thread

Re: Question about circular imports "Frank Millman" <frank@chagford.com> - 2012-02-27 08:16 +0200
  Re: Question about circular imports "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2012-02-28 03:55 +0000
    Re: Question about circular imports Ethan Furman <ethan@stoneleaf.us> - 2012-02-28 09:58 -0800

csiph-web