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


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

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

Started byrobert <robert@redcor.ch>
First post2018-03-01 10:38 +0100
Last post2018-03-01 10:38 +0100
Articles 1 — 1 participant

Back to article view | Back to de.comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

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

Fromrobert <robert@redcor.ch>
Date2018-03-01 10:38 +0100
Subject[Python-de] Verständnis-Problem mit python3 import
Message-ID<mailman.161.1519897543.2835.python-de@python.org>
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

[toc] | [standalone]


Back to top | Article view | de.comp.lang.python


csiph-web