Re: Best way to do this? List loop (matrix?) iteration

2013-01-09 Thread Dave Angel
On 01/09/2013 06:24 PM, andydtay...@gmail.com wrote: > Thanks for your help - this is what I did - though it's probably obvious to > most people reading this. > >for rowcount in range (0, stn_count): > row_durations.append(stn_list_short[rowcount]) > for colcount in range (0, stn_c

Re: Best way to do this? List loop (matrix?) iteration

2013-01-09 Thread andydtaylor
Thanks for your help - this is what I did - though it's probably obvious to most people reading this. for rowcount in range (0, stn_count): row_durations.append(stn_list_short[rowcount]) for colcount in range (0, stn_count): # 3. Determine Station pairs for API query

Re: Best way to do this? List loop (matrix?) iteration

2013-01-08 Thread Chris Angelico
On Wed, Jan 9, 2013 at 11:19 AM, wrote: >stn_count = len(stn_list_short) >for rowcount in range (0, stn_count): > for colcount in range (0, stn_count): > print stn_list_long[rowcount] stn_list_long[colcount] First off, you can iterate over the list directly: for row in st

Re: Best way to do this? List loop (matrix?) iteration

2013-01-08 Thread Mitya Sirenef
On Tue 08 Jan 2013 07:19:59 PM EST, andydtay...@gmail.com wrote: Hi! I might be missing the obvious, or I may have found something more complicated than the VBA I am used to. Could it be I need to use a maths library? For a given list of k items I'd like to turn it into an k*k matrix of item

Best way to do this? List loop (matrix?) iteration

2013-01-08 Thread andydtaylor
Hi! I might be missing the obvious, or I may have found something more complicated than the VBA I am used to. Could it be I need to use a maths library? For a given list of k items I'd like to turn it into an k*k matrix of item pairs. List_sample = ['a', 'b', 'c'] Output: aa ab ac ba bb bc c

Re: best way to do this

2008-12-02 Thread alex23
On Dec 3, 1:38 pm, thor <[EMAIL PROTECTED]> wrote: > >>> c = [(5, 3), (6, 8)] > >>> [x for t in zip(*c) for x in t] > [5, 6, 3, 8] The zip here is superfluous. >>> c = [(5, 3), (6, 8)] >>> zip(*c) [(5, 6), (3, 8)] Unless you're -only- using it to ensure your result is the same order as the OP...

Re: best way to do this

2008-12-02 Thread thor
On Dec 2, 10:09 pm, TP <[EMAIL PROTECTED]> wrote: > Hi everybody, > > >>> c=[(5,3), (6,8)] > > From c, I want to obtain a list with 5,3,6, and 8, in any order. > I do this: > > >>> [i for (i,j) in c] + [ j for (i,j) in c] > > [5, 6, 3, 8] > > Is there a quicker way to do this? > >>> c = [(5, 3), (

Re: best way to do this

2008-12-02 Thread Arnaud Delobelle
On Dec 2, 2:09 pm, TP <[EMAIL PROTECTED]> wrote: > Hi everybody, > > >>> c=[(5,3), (6,8)] > > From c, I want to obtain a list with 5,3,6, and 8, in any order. > I do this: > > >>> [i for (i,j) in c] + [ j for (i,j) in c] > > [5, 6, 3, 8] > > Is there a quicker way to do this? > One list comprehens

Re: best way to do this

2008-12-02 Thread Hrvoje Niksic
TP <[EMAIL PROTECTED]> writes: > Hi everybody, > c=[(5,3), (6,8)] > > From c, I want to obtain a list with 5,3,6, and 8, in any order. > I do this: > [i for (i,j) in c] + [ j for (i,j) in c] > [5, 6, 3, 8] > > Is there a quicker way to do this? Quicker? Hard to say. Using itertools el

Re: best way to do this

2008-12-02 Thread Diez B. Roggisch
TP wrote: > Hi everybody, > c=[(5,3), (6,8)] > > From c, I want to obtain a list with 5,3,6, and 8, in any order. > I do this: > [i for (i,j) in c] + [ j for (i,j) in c] > [5, 6, 3, 8] > > Is there a quicker way to do this? dunno if it's faster, but less cluttered: list(sum(c, ()))

best way to do this

2008-12-02 Thread TP
Hi everybody, >>> c=[(5,3), (6,8)] >From c, I want to obtain a list with 5,3,6, and 8, in any order. I do this: >>> [i for (i,j) in c] + [ j for (i,j) in c] [5, 6, 3, 8] Is there a quicker way to do this? Thanks Julien -- python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.9&1+,\

Re: best way to do this ...

2005-05-17 Thread Tonino
hmm - but I want to store the data in memory eather than a filesystem ... it is not an issue if the program terminates - it is almost needed while running and does not need to remember where it is .. the dirctionary is detail = {} will try the list() function - thanks Tonino -- http://mail.pyt

Re: best way to do this ...

2005-05-17 Thread Thomas Guettler
Am Tue, 17 May 2005 05:26:15 -0700 schrieb Tonino: > Hi ALL, > > I am having a issue with a particular storage of data problem and > wanted to know if I am going about it the wrong way. > > I have a list of reference numbers associated with a product and I have > a socket that listens on a port.

best way to do this ...

2005-05-17 Thread Tonino
Hi ALL, I am having a issue with a particular storage of data problem and wanted to know if I am going about it the wrong way. I have a list of reference numbers associated with a product and I have a socket that listens on a port. Now what happens is the client app connects to the server - send