Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Peter Otten <__peter__@web.de> Newsgroups: comp.lang.python Subject: Re: Controlling the passing of data Date: Thu, 28 Apr 2016 15:40:23 +0200 Organization: None Lines: 36 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de MKKK9uC0i42yDQtNOE5NRQR20MFtB1rDyYq1nF+rW7vA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'skip:[ 20': 0.03; 'modify': 0.04; 'guido': 0.05; 'desired.': 0.07; 'alter': 0.09; 'english,': 0.09; 'indication': 0.09; 'iterate': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'causing': 0.13; 'advice:': 0.16; 'occurence': 0.16; 'optionally': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'repetitions': 0.16; 'snippets': 0.16; 'traverse': 0.16; 'wrote:': 0.16; 'python?': 0.18; 'variable': 0.18; 'code.': 0.23; 'bit': 0.23; 'xml': 0.24; 'header :User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'least': 0.27; 'pieces': 0.27; 'function': 0.28; "skip:' 10": 0.28; 'actual': 0.28; 'looks': 0.29; 'repair': 0.29; 'code': 0.30; 'putting': 0.30; 'problem': 0.33; 'source': 0.33; 'structure': 0.34; 'file': 0.34; 'running': 0.34; 'list': 0.34; 'clear': 0.35; 'comment': 0.35; 'too': 0.36; 'should': 0.36; 'needed': 0.36; 'possible.': 0.36; 'flow': 0.36; 'limitation': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'format': 0.39; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'called': 0.40; 'your': 0.60; 'provide': 0.61; 'here': 0.66; 'finally': 0.70; 'restore': 0.70; 'race': 0.72; 'car': 0.72 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: p57bd9524.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com comp.lang.python:107790 Sayth Renshaw wrote: > In my file here I needed to traverse and modify the XML file I don't want > to restore it or put it in a new variable or other format I just want to > alter it and let it flow onto the list comprehensions as they were. That looks like an arbitrary limitation to me. It's a bit like "I want to repair my car with this big hammer". > In particular here I am taking the id from race and putting it into the > children of each race called nomination. > > I have put a comment above the new code which is causing the difficulty. Your actual problem is drowned in too much source code. Can you restate it in English, optionally with a few small snippets of Python? It is not even clear what the code you provide should accomplish once it's running as desired. To give at least one code-related advice: You have a few repetitions of the following structure > meetattrs = ('id', 'venue', 'date', 'rail', 'weather', 'trackcondition') > meet = d('meeting') > meetdata = [[meet.eq(i).attr(x) > for x in meetattrs] for i in range(len(meet))] You should move the pieces into a function that works for meetings, clubs, races, and so on. Finally (If I am repeating myself so be it): the occurence of range(len(something)) in your code is a strong indication that you are not using Python the way Guido intended it. Iterate over the `something` directly whenever possible.