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


Groups > de.comp.lang.python > #5127

[Python-de] Verständnis-Problem mit python3 import

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From robert <robert@redcor.ch>
Newsgroups de.comp.lang.python
Subject [Python-de] Verständnis-Problem mit python3 import
Date Thu, 1 Mar 2018 10:38:08 +0100
Lines 52
Message-ID <mailman.161.1519897543.2835.python-de@python.org> (permalink)
References <8df4c688-813f-74c4-9523-f9ed0a4b00ae@redcor.ch>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de BOsD02/+alYU0VTJxvIxVQ8CBdCajAWDRXkrhjSrJLNg==
Return-Path <robert@redcor.ch>
X-Original-To python-de@python.org
Delivered-To python-de@mail.python.org
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0
Content-Language en-GB
X-BeenThere python-de@python.org
X-Mailman-Version 2.1.26
Precedence list
List-Id Die Deutsche Python Mailingliste <python-de.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-de/>
List-Post <mailto:python-de@python.org>
List-Help <mailto:python-de-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <8df4c688-813f-74c4-9523-f9ed0a4b00ae@redcor.ch>
Xref csiph.com de.comp.lang.python:5127

Show key headers only | View raw


Hoi zäme,

Ich bin dabei ein Aplikation von 2.7 nach 3.6 zu migrieren.

Nun habe ich ein Problem den Mechanismus von Python 3.6 import zu verstehen.

in einem modul config habe ich eine __init__.py datei.

Die beginnt so:

# -*- encoding: utf-8 -*-
import os
import sys
from . import globaldefaults
GD = globaldefaults.GLOBALDEFAULTS
from globaldefaults import GLOBALDEFAULTS

wenn ich das modul in 2.7 lade funktioniert es wie gewünscht, nicht aber in 3.6

robert@chrissy:~/bridge-builder$ python3.6
Python 3.6.4 (default, Jan 28 2018, 17:52:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import config
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/home/robert/bridge-builder/config/__init__.py", line 6, in <module>
     from globaldefaults import GLOBALDEFAULTS
ModuleNotFoundError: No module named 'globaldefaults'


was mich hier verblüfft, ist dass ich

from . import globaldefaults
GD = globaldefaults.GLOBALDEFAULTS

ausführen kann,

nicht aber

from globaldefaults import GLOBALDEFAULTS

was mach ich da falsch??


danke

robert

Back to de.comp.lang.python | Previous | Next | Find similar


Thread

[Python-de] Verständnis-Problem mit python3 import robert <robert@redcor.ch> - 2018-03-01 10:38 +0100

csiph-web