Re: nested looping

2009-04-08 Thread andrew cooke
bit late here, but if it's as simple as you say, i think it would be much more efficient (because you only scan checklist and alist once each) to do: known = set() for check in checklist: known.add(check[0:-1]) missing = filter(lambda alpha: alpha not in known, alist) andrew PK wrote: > Exce

Re: nested looping

2009-04-08 Thread PK
Excellent! Thanks all. Since I need to have this running on python 2.4 as well, I think I'll choose, for alpha in alist: for xy in xlist: if alpha+xy in checklist: break else: missing.append(alpha) jus tested and worked like a charm. Appreciate your help!! On W

Re: nested looping

2009-04-08 Thread Luis Alberto Zarrabeitia Gomez
Quoting PK : > So I'm trying to see whats the cleanest way to do this: > > I have a > > checklist = [ax, bx, by, cy ..] (a combination of a,b,c with x and y, > either both on one) > > allist = [a,b,c,] > xlist = [x, y, ..] > [...] > now the problem is I want to include alpha in missing l

Re: nested looping

2009-04-08 Thread Matimus
On Apr 8, 2:15 pm, PK wrote: > So I'm trying to see whats the cleanest way to do this: > > I have a > > checklist = [ax, bx, by, cy  ..] (a combination of a,b,c with x and y, > either both on one) > > allist = [a,b,c,] > xlist = [x, y, ..] > > now I wanna loop through alist and xlist and see i

Re: nested looping

2009-04-08 Thread Terry Reedy
PK wrote: So I'm trying to see whats the cleanest way to do this: I have a checklist = [ax, bx, by, cy ..] (a combination of a,b,c with x and y, either both on one) Since you will be repeatedly looking for items in checklist, I suggest making it a set instead. allist = [a,b,c,] xlist

nested looping

2009-04-08 Thread PK
So I'm trying to see whats the cleanest way to do this: I have a checklist = [ax, bx, by, cy ..] (a combination of a,b,c with x and y, either both on one) allist = [a,b,c,] xlist = [x, y, ..] now I wanna loop through alist and xlist and see if the combination exists in checklist so someth

Re: Nested Looping SQL Querys

2006-09-21 Thread Steve Holden
Carsten Haese wrote: > On Thu, 2006-09-21 at 01:12, Dennis Lee Bieber wrote: > >>On Wed, 20 Sep 2006 13:21:54 -0400, Steve Holden <[EMAIL PROTECTED]> >>declaimed the following in comp.lang.python: >> >> >>>.execute() is a cursor method, not a connection method. Some DB API >>>modules do implement

Re: Nested Looping SQL Querys

2006-09-21 Thread Carsten Haese
On Thu, 2006-09-21 at 01:12, Dennis Lee Bieber wrote: > On Wed, 20 Sep 2006 13:21:54 -0400, Steve Holden <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > .execute() is a cursor method, not a connection method. Some DB API > > modules do implement it as a connection method,

Re: Nested Looping SQL Querys

2006-09-20 Thread Steve Holden
Dennis Lee Bieber wrote: [...] > # not conn.execute() ? That's what all the DB-API compliant adapters > use > > result = conn.execute(sql, params) > .execute() is a cursor method, not a connection method. Some DB API modules do implement it as a connection method, but that makes it impo

Re: Nested Looping SQL Querys

2006-09-20 Thread Steve Holden
Bruno Desthuilliers wrote: > Fuzzydave wrote: > > (snip) > """ > pubID=cgiForm.getvalue('pubID') > pubName=cgiForm.getvalue('pubName','Unknown Publication') > > sqlcheck1 = "SELECT pub_type FROM medusa.cmi_publication WHERE pub_id = > '"+pubID+"'" > overseas1 = conn.query(sqlcheck1) > pubType = c

Re: Nested Looping SQL Querys

2006-09-20 Thread Bruno Desthuilliers
Fuzzydave wrote: > I am back developing futher our Python/CGI based web application run by > a Postgres DB > and as per usual I am having some issues. It Involves a lot of Legacy > code. s/Legacy/Norwegian Blue/ -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.spl

Re: Nested Looping SQL Querys

2006-09-20 Thread Bruno Desthuilliers
Fuzzydave wrote: (snip) """ pubID=cgiForm.getvalue('pubID') pubName=cgiForm.getvalue('pubName','Unknown Publication') sqlcheck1 = "SELECT pub_type FROM medusa.cmi_publication WHERE pub_id = '"+pubID+"'" overseas1 = conn.query(sqlcheck1) pubType = cmi.fetch_rows(overseas1) """ May we have the url

Nested Looping SQL Querys

2006-09-20 Thread Fuzzydave
I am back developing futher our Python/CGI based web application run by a Postgres DB and as per usual I am having some issues. It Involves a lot of Legacy code. All the actual SQL Querys are stored in the .py files and run in the .cgi files. I have the problem that I need to construct a row from t