Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109092
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Gerald Britton <gerald.britton@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Question about imports and packages |
| Date | Tue, 24 May 2016 19:35:58 -0400 |
| Lines | 45 |
| Message-ID | <mailman.70.1464132967.20402.python-list@python.org> (permalink) |
| References | <CAPxRSnYXQL-0zTo81_QmhXan6nJ-fzCBpS6y5DjqS952SV=yjg@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de 9oTvB/ryV2pomvs64r824QuIaXDRi6De7N/0c16sC1KQ== |
| Return-Path | <gerald.britton@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'importerror:': 0.05; 'subject:Question': 0.05; 'files:': 0.09; 'imports': 0.09; 'python': 0.10; 'packages.': 0.15; '5px': 0.16; '6px': 0.16; '8px': 0.16; '__init__.py': 0.16; 'a()': 0.16; 'a():': 0.16; 'missing?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:r 80': 0.16; 'case.': 0.18; 'doc': 0.22; 'pass': 0.22; 'trying': 0.22; 'absolute': 0.23; 'import': 0.24; '(most': 0.24; 'module': 0.25; 'message-id:@mail.gmail.com': 0.27; '8bit%:3': 0.27; 'references.': 0.29; "i'm": 0.30; 'print': 0.30; "can't": 0.32; 'especially': 0.32; 'skip:_ 10': 0.32; 'run': 0.33; 'class': 0.33; 'problem': 0.33; 'url:python': 0.33; 'traceback': 0.33; 'file': 0.34; 'skip:& 20': 0.35; 'received:google.com': 0.35; 'url:org': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'skip:& 10': 0.37; 'received:209.85.213': 0.37; 'skip:5 10': 0.37; 'thought': 0.37; 'doing': 0.38; 'received:209': 0.38; 'to:addr:python.org': 0.40; 'href=""': 0.66; '1px': 0.76; 'url:tutorial': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=bhZkIhYtnLO5tzGOvc0pXoizAhww/AKiyeerXxUHrKg=; b=e4KvfJWeHj7gtqRhhZs291/hiaCnOKTvT7ygDSKebnQU+UfghO85WfxGR0J3BBs+Id YJruxsR+XOdWQQ7z80oMQwTnwcjYpvxae099dvJH8hJcVbpZ7WYlm4+GGzXNylc/MYuL AJiC4hwI4+znPCCmMhPLIyhvu5SfUFdYjEJK955t2v/Z98hJTDCIN6FPio+kIzPC65Ms E8SfbM77mMhT78rbYvX85Bksof4ITrXbMczEzylpEaFH5Jhql7SDG5B2fJRqrOnBoYD8 SlcA3eXH0Aw7Kc2QRw8PSMt4A9aE2RYiJ4ZDa9oAUIaW83OglZA37IedCYcLjEuZxvJn kStA== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=bhZkIhYtnLO5tzGOvc0pXoizAhww/AKiyeerXxUHrKg=; b=Yppk81spUBxAP10CowKoA3uhqiQZF8RoPWyBz0ZYzBI5wXZyWR+QHwy0/EJ0mA/YuT 0511yjivRudns0UFxrqZ/0Eqb0uuKpGU8+0RBEpyGjMtMU6bDOTfjwJhAvh2tM/0iTv5 5miKQEtyGOTeZqjHRBZNSnWHaCLvxbaijkVIhIFFQEJZw5zA88rqknRujn04ea1mdm3m y0phnYc3cNQtdx3vohxOkt6hbtLeOgVpO+tmX1xEcp+X/5qQcqCrxs55plJLC+2jj1ek BmybX3zEt1BFZ47CMN+9Xmdlk4hvyNUrCOJsbirm1iBoGbDvOiz+ajpF30LWYCVYsbTJ Xm7Q== |
| X-Gm-Message-State | ALyK8tIrk09lOEwkc6mjKlOczPNFE7CljTSaxgUBR/pongIJgOjzC1qa0YK3pFxzmNgbcupC71S1do614IFLtA== |
| X-Received | by 10.50.19.231 with SMTP id i7mr13986877ige.0.1464132958444; Tue, 24 May 2016 16:35:58 -0700 (PDT) |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.22 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| 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> |
| X-Mailman-Original-Message-ID | <CAPxRSnYXQL-0zTo81_QmhXan6nJ-fzCBpS6y5DjqS952SV=yjg@mail.gmail.com> |
| Xref | csiph.com comp.lang.python:109092 |
Show key headers only | View raw
I'm trying to understand packages in Python, especially Intra Package
References.
>From https://docs.python.org/2/tutorial/modules.html#packages i see that:
you can use absolute imports to refer to submodules of siblings packages.
This is what I can't get to work in my case. Here's the setup:
directory testpkg containing three files:
1. an empty __init__.py
2. a testimport.py which has:
from testpkg.testimported import A
a = A()
print type(a)
3. a testimported.py which has:
class A():
pass
When I run
python testimport.py
I get:
Traceback (most recent call last):
File "testimport.py", line 1, in <module>
from testpkg.testimported import A
ImportError: No module named testpkg.testimported
However, I thought I was doing what the doc describes for intra package
imports. What am I missing?
Or is the problem simply that I do not have subpackages?
--
Gerald Britton
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Question about imports and packages Gerald Britton <gerald.britton@gmail.com> - 2016-05-24 19:35 -0400
Re: Question about imports and packages Steven D'Aprano <steve@pearwood.info> - 2016-05-25 11:02 +1000
Re: Question about imports and packages Terry Reedy <tjreedy@udel.edu> - 2016-05-24 23:36 -0400
csiph-web