Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.python > #5400

Re: [Python-de] import Problem

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Hermann Riemann <nospam.ng@hermann-riemann.de>
Newsgroups de.comp.lang.python
Subject Re: [Python-de] import Problem
Date Fri, 11 Jan 2019 15:42:14 +0100
Lines 128
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>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace individual.net xEAscKaT6qZHjZC5R1n4MAZu/FK7yh8f2wFd+pY+fz1uUQxHju
Cancel-Lock sha1:KNrudx7EZ2WWDggJnmj1PsjL/j8=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0
In-Reply-To <mailman.194.1547202519.4816.python-de@python.org>
Content-Language de-DE
Xref csiph.com de.comp.lang.python:5400

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar


Thread

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