Re: Coding Nested Loops

2006-09-16 Thread Rich Shepard
On Sat, 16 Sep 2006, Dan Sommers wrote: > No, they all work the same way (thank goodness!). The "." between "wx" > and "frame" is the same dot as is between "random" and "choice" (i.e., > random.choice is the same construct as wx.frame). Ah, yes. I totally forgot this. Thanks for the reminde

Re: Coding Nested Loops

2006-09-16 Thread Dan Sommers
On Sat, 16 Sep 2006 10:06:25 -0700 (PDT), Rich Shepard <[EMAIL PROTECTED]> wrote: > On Sat, 16 Sep 2006, Dan Sommers wrote: >> When you import random, all you're doing is importing the module; you >> have to specify any given attribute thereof: > I thought that was implied. For example, I use

Re: Coding Nested Loops

2006-09-16 Thread Rich Shepard
On Sat, 16 Sep 2006, Dan Sommers wrote: > When you import random, all you're doing is importing the module; you have > to specify any given attribute thereof: Dan, I thought that was implied. For example, I use 'import wx' and can then instantiate wx.frame, wx.dialogbox, etc. without explicit

Re: Coding Nested Loops

2006-09-16 Thread Dan Sommers
On Sat, 16 Sep 2006 08:29:26 -0700 (PDT), Rich Shepard <[EMAIL PROTECTED]> wrote: > Two questions germane to random: 1) Why wasn't choice available when > I used 'import random,' ... When you import random, all you're doing is importing the module; you have to specify any given attribute thereo

Re: Coding Nested Loops

2006-09-16 Thread Rich Shepard
On Sat, 16 Sep 2006, Peter Otten wrote: > As George hinted, I went a bit over the top with my itertools example. > Here is a translation into static lists (mostly): Peter, Thank you. This is clearer to me. While your original code certainly works it reminded me of The C Users Journal's annual

Re: Coding Nested Loops

2006-09-15 Thread Peter Otten
Rich Shepard wrote: > On Fri, 15 Sep 2006, Peter Otten wrote: > >> It's not clear to me why you would use dictionaries, especially as they >> are unordered; I used lists instead: > >... > >> Now that is a nice occasion to get acquainted with the itertools >> module... > > Peter, > >I

Re: Coding Nested Loops

2006-09-15 Thread Rich Shepard
On Fri, 15 Sep 2006, Peter Otten wrote: > It's not clear to me why you would use dictionaries, especially as they > are unordered; I used lists instead: ... > Now that is a nice occasion to get acquainted with the itertools module... Peter, I have to study the docs to understand what's g

Re: Coding Nested Loops

2006-09-15 Thread George Sakkis
Peter Otten wrote: > from itertools import count, izip, cycle, chain, repeat, starmap, imap > from random import choice > > first = ["X", "Y", "Z"] > second = ["A", "B", "C"] > second_count = [13, 14, 33] > third = [1.1, 2.2, 3.3, 4.4] > > random_floats = imap(choice, repeat(third)) > columns = [

Re: Coding Nested Loops

2006-09-15 Thread Rich Shepard
On Fri, 15 Sep 2006, Bjoern Schliessmann wrote: That doesn't answer the question. A list of 2-tuples would do the same (and was ordered and could be indexed). Björn, et al.: For the purpose of generating a data sample, the list of 2-tuples will work. Thanks all, Rich -- Richard B. Shepar

Re: Coding Nested Loops

2006-09-15 Thread Bjoern Schliessmann
Rich Shepard wrote: > On Fri, 15 Sep 2006, Peter Otten wrote: >> It's not clear to me why you would use dictionaries, especially >> as they are unordered; I used lists instead: >Because the data comes via a serial port as sequences of two >bytes from an > OMR reader, and the byte pairs n

Re: Coding Nested Loops

2006-09-15 Thread Rich Shepard
On Fri, 15 Sep 2006, Peter Otten wrote: > It's not clear to me why you would use dictionaries, especially as they > are unordered; I used lists instead: Peter, Because the data comes via a serial port as sequences of two bytes from an OMR reader, and the byte pairs need to be converted into v

Re: Coding Nested Loops

2006-09-15 Thread Peter Otten
Rich Shepard wrote: >I want to code what would be nested "for" loops in C, but I don't know >the > most elegant way of doing the same thing in python. So I need to learn how > from you folks. Here's what I need to do: build a database table of 180 > rows. Each row contains 31 columns: the

Coding Nested Loops

2006-09-15 Thread Rich Shepard
I want to code what would be nested "for" loops in C, but I don't know the most elegant way of doing the same thing in python. So I need to learn how from you folks. Here's what I need to do: build a database table of 180 rows. Each row contains 31 columns: the first is an automatically incremen