Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #5128
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Hartmut Goebel <h.goebel@goebel-consult.de> |
| Newsgroups | de.comp.lang.python |
| Subject | Re: [Python-de] Verständnis-Problem mit python3 import |
| Date | Thu, 1 Mar 2018 12:21:25 +0100 |
| Organization | Goebel Consult |
| Lines | 57 |
| Message-ID | <mailman.163.1519903295.2835.python-de@python.org> (permalink) |
| References | <8df4c688-813f-74c4-9523-f9ed0a4b00ae@redcor.ch> <9ec5fcde-954f-0fae-ea40-0d2f395d2ec1@goebel-consult.de> |
| Mime-Version | 1.0 |
| Content-Type | multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="------------ms040505050807000401060905" |
| X-Trace | news.uni-berlin.de RnvPyMCFw324DipCm4b+Aw4IuRtr+pdgFfljE5ct5mpw== |
| Return-Path | <h.goebel@goebel-consult.de> |
| X-Original-To | python-de@python.org |
| Delivered-To | python-de@mail.python.org |
| X-Virus-Scanned | amavisd-new at mnet-online.de |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
| In-Reply-To | <8df4c688-813f-74c4-9523-f9ed0a4b00ae@redcor.ch> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.26 |
| 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 | <9ec5fcde-954f-0fae-ea40-0d2f395d2ec1@goebel-consult.de> |
| X-Mailman-Original-References | <8df4c688-813f-74c4-9523-f9ed0a4b00ae@redcor.ch> |
| Xref | csiph.com de.comp.lang.python:5128 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Am 01.03.2018 um 10:38 schrieb robert: > from . import globaldefaults > from globaldefaults import GLOBALDEFAULTS Laut Syntax kommt [1] nach dem "from" ein "relative_module", als der Name eines Modules. Das zweite import-Statement verwendet also nicht den Identifier "globaldefaults" sondern sucht das Modul mit dem Namen "globaldefaults". In Python 2 funktioniert das so, wie Du es erwartet, weil "globaldefaults" als relativer Import interpretiert wird. In Python 3 ist es aber ein absoluter Import - und ein globales Module/Package "globaldefaults" hast Du nicht. Für python 3 muss also das zweite Import-Statement lauten (funktioniert auch mit Python 2.7): from .globaldefaults import GLOBALDEFAULTS [1] https://docs.python.org/3/reference/simple_stmts.html#the-import-statement -- Schönen Gruß Hartmut Goebel Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer Information Security Management, Security Governance, Secure Software Development Goebel Consult, Landshut http://www.goebel-consult.de Blog: http://www.goebel-consult.de/blog/eilt-petition-auf-weact-gegen-vds-jetzt-unterschreiben Kolumne: http://www.cissp-gefluester.de/2011-09-kommerz-uber-recht-fdp-die-gefaellt-mir-partei
Back to de.comp.lang.python | Previous | Next | Find similar
Re: [Python-de] Verständnis-Problem mit python3 import Hartmut Goebel <h.goebel@goebel-consult.de> - 2018-03-01 12:21 +0100
csiph-web