Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #5397
| From | Achim Herwig <python@wodca.de> |
|---|---|
| Newsgroups | de.comp.lang.python |
| Subject | Re: [Python-de] import Problem |
| Date | 2019-01-11 11:28 +0100 |
| Message-ID | <mailman.194.1547202519.4816.python-de@python.org> (permalink) |
| References | <g9r8r8Ffq9nU1@mid.individual.net> <ED4FA3F9-31C6-4025-BB09-F1FF7E8E7736@wodca.de> |
> Am 11.01.2019 um 11:18 schrieb Hermann Riemann <nospam.ng@hermann-riemann.de>:
>
> Gegeben große Datei mit
>
> z=6
>
> def a():
> global z
> # viel code
> print("in a")
> z-=1
> if z>0: b()
> # viel code
>
> def b():
> global z
> # viel code
> print("in b")
> a()
> # viel code
>
> Die soll zerlegt werden in
> ma.py:
>
# fehlt:
from mb import *
> z=6
>
> def a():
> global z
> # viel code
> print("in a")
> z-=1
> if z>0: b()
> # viel code
>
> mb.py:
>
# fehlt:
from ma import *
> def b():
> global z
> # viel code
> print("in b")
> a()
> # viel code
>
> Der Aufruf von
>
> from ma import *
> from mb import *
>
> a()
>
> liefert:
> Traceback (most recent call last):
> File "mm.py", line 4, in <module>
> a()
> File "/y/g/py.modul/ma.py", line 8, in a
> if z>0: b()
> NameError: name 'b' is not defined
>
> Hermann
> der gerne große Dateien mit Python3
> Programmen zerlegen würde,
> 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 <https://docs.python.org/3/tutorial/modules.html> lesen könnte...
VG, Achim.
--
Achim Herwig <python@wodca.de>
Back to de.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
import Problem Hermann Riemann <nospam.ng@hermann-riemann.de> - 2019-01-11 11:18 +0100
Re: [Python-de] import Problem Achim Herwig <python@wodca.de> - 2019-01-11 11:28 +0100
Re: [Python-de] import Problem Hermann Riemann <nospam.ng@hermann-riemann.de> - 2019-01-11 15:42 +0100
Re: [Python-de] import Problem Peter Otten <__peter__@web.de> - 2019-01-11 15:33 +0100
Re: [Python-de] import Problem Hermann Riemann <nospam.ng@hermann-riemann.de> - 2019-01-11 17:09 +0100
csiph-web