Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #5400
| From | Hermann Riemann <nospam.ng@hermann-riemann.de> |
|---|---|
| Newsgroups | de.comp.lang.python |
| Subject | Re: [Python-de] import Problem |
| Date | 2019-01-11 15:42 +0100 |
| Message-ID | <g9roa6Fj5fhU1@mid.individual.net> (permalink) |
| References | <g9r8r8Ffq9nU1@mid.individual.net> <ED4FA3F9-31C6-4025-BB09-F1FF7E8E7736@wodca.de> <mailman.194.1547202519.4816.python-de@python.org> |
Am 11.01.19 um 11:28 schrieb Achim Herwig:
>> 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
Wohl nicht.:
> python3 mm.py
in a
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
>for i in *.py;do echo "***************" $i;cat $i;done
*************** ma.py
z=6
def a():
global z
# viel code
print("in a")
z-=1
if z>0: b()
# viel code
*************** mb.py
from ma import *
def b():
global z
# viel code
print("in b")
a()
# viel code
*************** mm.py
from ma import *
from mb import *
a()
*************** o.py
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
a()
Bei import scheint zu gelten:
a will b vorher haben,
b will a vorher haben,
Hermann
der einen großes Programm
gerne zerlegen würde,
aber dann obigen Problemtyp hat.
--
http://www.hermann-riemann.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