multiplication of lists of strings

J

Jason

How could I return a list or tuple of each unique combination of a given
set of lists (perhaps from a dict or a list). This means the number of
lists are not known nor is the length of each.

Here is an example:
fruit = ['apple', 'orange']
numbers = ['one', 'two', 'three']
names = ['joe']

Order matters (I started by trying to iterate over a list corresponding
to keys in the dict that contains these lists). Furthermore, (a, b) is
different from (b, a) however I will filter out all but unique (a, a) if
that occurs.

Once this step is solved, I then will use each tuple as a key in a dict.

I appreciate any assistance you can throw my way.

Jason G
 
C

castironpi

found it, the referenced cookbook recipe is perfect.

Thanks, Gabriel

That reminds me: Is there a generic 'relation' pattern/recipie, such
as finding a computer that's "paired" with multiple users, each of who
are "paired" with multiple computers, without maintaining dual-
associativity?

Good:

py> user.getcomputers()
[ Compie1, Compie2 ]

Bad:

user._computers.add( compieN )
compieN._users.add( user )

?
 
B

Bruno Desthuilliers

(e-mail address removed) a écrit :
(snip)
That reminds me: Is there a generic 'relation' pattern/recipie, such
as finding a computer that's "paired" with multiple users, each of who
are "paired" with multiple computers, without maintaining dual-
associativity?
Yes : use a relational database.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top