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


Groups > comp.lang.python > #18826

import problems.

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <antoon.pardon@rece.vub.ac.be>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'received:134': 0.05; 'sys': 0.05; 'importerror:': 0.07; 'python': 0.08; '__name__': 0.09; 'problem:': 0.09; 'ats': 0.16; 'subject:import': 0.16; 'this:': 0.16; '(most': 0.21; 'figure': 0.23; 'debian': 0.23; 'traceback': 0.24; 'import': 0.27; 'problem': 0.29; 'print': 0.29; 'imported': 0.30; "can't": 0.32; 'header:User-Agent:1': 0.33; 'to:addr:python-list': 0.34; 'calling': 0.34; 'last):': 0.34; 'skip:" 50': 0.34; 'file': 0.36; 'but': 0.37; 'using': 0.38; 'skip:- 50': 0.39; 'why': 0.39; 'to:addr:python.org': 0.40; 'join': 0.61
X-IronPort-Anti-Spam-Filtered true
X-IronPort-Anti-Spam-Result AjAOAOiLDU+GuA9G/2dsb2JhbABDh2ioNUA9FhgDAgECAVgIAp9Tn2iDfYUEgxwElQyFPox/
Date Wed, 11 Jan 2012 14:21:57 +0100
From Antoon Pardon <antoon.pardon@rece.vub.ac.be>
User-Agent Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Icedove/3.0.11
MIME-Version 1.0
To python-list@python.org
Subject import problems.
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
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.4644.1326288187.27778.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1326288187 news.xs4all.nl 6982 [2001:888:2000:d::a6]:52622
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18826

Show key headers only | View raw


I have an import problem I can't figure out.
I am using python 2.6.6 on a debian box

In one directory (pylib) I have a file misc.py and
the file testutil.py.

-------------------- testutil.py ----------------------

print "in", __name__

from misc import Rec

--------------------------------------------------------

calling this file in that directory gives me this:

$ python testutil.py
in __main__

In a neighbour directory I have the file ats

------------------------ atst ----------------------------

import sys

from os.path import join as pj, abspath

print abspath("../pylib")

sys.path.append(abspath("../pylib"))

import testutil

-----------------------------------------------------------

Now calling this file in its directory gives me the following problem:
$ python atst
/local/home/apardon/src/projecten/pylib
in testutil
Traceback (most recent call last):
   File "atst", line 9, in <module>
     import testutil
   File "/local/home/apardon/src/projecten/pylib/testutil.py", line 4, 
in <module>
     from misc import Rec
ImportError: cannot import name Rec

Why can I import Rec from misc in testutil when I call testutil.py 
directly but not when testutil was imported itself?

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


Thread

import problems. Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2012-01-11 14:21 +0100

csiph-web