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


Groups > comp.lang.python > #107790

Re: Controlling the passing of data

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 <mailman.189.1461850832.32212.python-list@python.org> (permalink)
References <afa1ab1d-6d6a-421c-9351-c8805cc5fbea@googlegroups.com> <nft3s8$3ku$1@ger.gmane.org>
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 <python-python-list@m.gmane.org>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <nft3s8$3ku$1@ger.gmane.org>
X-Mailman-Original-References <afa1ab1d-6d6a-421c-9351-c8805cc5fbea@googlegroups.com>
Xref csiph.com comp.lang.python:107790

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Controlling the passing of data Sayth Renshaw <flebber.crue@gmail.com> - 2016-04-28 05:02 -0700
  Re: Controlling the passing of data Peter Otten <__peter__@web.de> - 2016-04-28 15:40 +0200
    Re: Controlling the passing of data Sayth Renshaw <flebber.crue@gmail.com> - 2016-04-28 06:59 -0700
      RE: Controlling the passing of data Dan Strohl <D.Strohl@F5.com> - 2016-04-28 15:19 +0000
        Re: Controlling the passing of data Sayth Renshaw <flebber.crue@gmail.com> - 2016-04-28 18:49 -0700
      Re: Controlling the passing of data Peter Otten <__peter__@web.de> - 2016-04-29 13:26 +0200
        Re: Controlling the passing of data Sayth Renshaw <flebber.crue@gmail.com> - 2016-04-29 06:17 -0700
      Re: Controlling the passing of data Peter Otten <__peter__@web.de> - 2016-04-29 13:36 +0200
  RE: Controlling the passing of data Dan Strohl <D.Strohl@F5.com> - 2016-04-28 14:40 +0000
    Re: Controlling the passing of data Rustom Mody <rustompmody@gmail.com> - 2016-04-28 07:52 -0700

csiph-web