Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Achim Herwig Newsgroups: de.comp.lang.python Subject: Re: [Python-de] import Problem Date: Fri, 11 Jan 2019 11:28:31 +0100 Lines: 85 Message-ID: References: Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de GE3/bre3I0vsxSGmUxUejwehWBjQDNoEAUoABiI1yHgg== Return-Path: X-Original-To: python-de@python.org Delivered-To: python-de@mail.python.org In-Reply-To: X-Mailer: Apple Mail (2.3445.102.3) X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: python-de@python.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Die Deutsche Python Mailingliste List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com de.comp.lang.python:5397 > Am 11.01.2019 um 11:18 schrieb Hermann Riemann = : >=20 > Gegeben gro=C3=9Fe Datei mit >=20 > z=3D6 >=20 > def a(): > global z > # viel code > print("in a") > z-=3D1 > if z>0: b() > # viel code >=20 > def b(): > global z > # viel code > print("in b") > a() > # viel code >=20 > Die soll zerlegt werden in > ma.py: >=20 # fehlt: from mb import * > z=3D6 >=20 > def a(): > global z > # viel code > print("in a") > z-=3D1 > if z>0: b() > # viel code >=20 > mb.py: >=20 # fehlt: from ma import * > def b(): > global z > # viel code > print("in b") > a() > # viel code >=20 > Der Aufruf von >=20 > from ma import * > from mb import * >=20 > a() >=20 > liefert: > Traceback (most recent call last): > File "mm.py", line 4, in > a() > File "/y/g/py.modul/ma.py", line 8, in a > if z>0: b() > NameError: name 'b' is not defined >=20 > Hermann > der gerne gro=C3=9Fe Dateien mit Python3 > Programmen zerlegen w=C3=BCrde, > ohne obiges Problem zu haben, > oder es mit Tricks wie indirekter Programmaufruf > zu umgehen. und dazu mal https://docs.python.org/3/tutorial/modules.html = lesen k=C3=B6nnte... VG, Achim. -- =20 Achim Herwig =20