Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Hermann Riemann Newsgroups: de.comp.lang.python Subject: Re: [Python-de] import Problem Date: Fri, 28 Apr 2017 09:07:17 +0200 Lines: 33 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net uiE7sVRides2iVTVK5ba9g4RV8mBSs4xEUxv2dkWCz5XuiPtJa Cancel-Lock: sha1:+U5amEG0+whZyDfmPAh8zmsa3rw= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Xref: csiph.com de.comp.lang.python:4752 Am 28.04.2017 um 08:45 schrieb Christopher Arndt: >> Am 28.04.2017 um 07:55 schrieb Hermann Riemann : >> python3 p5.py >> liefert leider 0 > > Zum Glück tut es das, denn py3.x und p4.x sind unterschiedliche Variablen. In Python sind mit "global" deklarierte Variablen *modul*global, d.h. Jedes Modul hat seinen eigenen Namensraum. > > https://docs.python.org/3/tutorial/classes.html#python-scopes-and-namespaces Damit ist mein Problem nicht gelöst. Ein Einfügen als erste Zeile in p4.py von from p3 import * bewirkt keine Änderung im Ergebnis. Erst eine Änderung von von p4.y auf import p3 def f(): p3.x=1 wirkt Hermann der die Folgen von import p3 in p4.py gleichzeitig mit import p4 in p3.py nicht so recht überblickt. -- http://www.hermann-riemann.de