Velocity Reviews > multiplication of lists of strings

# multiplication of lists of strings

Jason
Guest
Posts: n/a

 03-05-2008
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

Gabriel Genellina
Guest
Posts: n/a

 03-05-2008
En Tue, 04 Mar 2008 23:50:49 -0200, Jason <(E-Mail Removed)> escribió:

> 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.

Use the Google interfase for this group:
Type "unique combinations lists" in the text box; press "Search in this
group". The very first result contains some answers to your question.

--
Gabriel Genellina

Jason Galyon
Guest
Posts: n/a

 03-05-2008
Gabriel Genellina wrote:
> En Tue, 04 Mar 2008 23:50:49 -0200, Jason <(E-Mail Removed)> escribió:
>
>> 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.

>
> Use the Google interfase for this group:
> Type "unique combinations lists" in the text box; press "Search in this
> group". The very first result contains some answers to your question.
>

found it, the referenced cookbook recipe is perfect.

Thanks, Gabriel

castironpi@gmail.com
Guest
Posts: n/a

 03-05-2008
On Mar 4, 9:46*pm, Jason Galyon <(E-Mail Removed)> wrote:
> Gabriel Genellina wrote:
> > En Tue, 04 Mar 2008 23:50:49 -0200, Jason <(E-Mail Removed)> escribió:

>
> >> 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.

>
> > Use the Google interfase for this group:
> > Type "unique combinations lists" in the text box; press "Search in this
> > group". The very first result contains some answers to your question.

>
> 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 ]

?

Bruno Desthuilliers
Guest
Posts: n/a

 03-05-2008
http://www.velocityreviews.com/forums/(E-Mail 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.

castironpi@gmail.com
Guest
Posts: n/a

 03-08-2008
On Mar 5, 2:16*am, Bruno Desthuilliers <bruno.
(E-Mail Removed)> wrote:
> (E-Mail 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.

No performance hit. Can I write an ad hoc relational class structure?

castironpi@gmail.com
Guest
Posts: n/a

 03-08-2008
On Mar 8, 12:04*pm, (E-Mail Removed) wrote:
> On Mar 5, 2:16*am, Bruno Desthuilliers <bruno.
>
> (E-Mail Removed)> wrote:
> > (E-Mail 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.

>
> No performance hit. *Can I write an ad hoc relational class structure?

What do you think of this solution?

http://jtauber.com/blog/2005/11/10/r...for_relations/