Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107790
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Controlling the passing of data |
| Date | 2016-04-28 15:40 +0200 |
| Organization | None |
| 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> |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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