Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > multiplication of lists of strings

Reply
Thread Tools

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
 
Reply With Quote
 
 
 
 
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:
http://groups.google.com/group/comp.lang.python/
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

 
Reply With Quote
 
 
 
 
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:
> http://groups.google.com/group/comp.lang.python/
> 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
 
Reply With Quote
 
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:
> >http://groups.google.com/group/comp.lang.python/
> > 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 ]

Bad:

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

?
 
Reply With Quote
 
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.
 
Reply With Quote
 
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?
 
Reply With Quote
 
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/

http://www.google.com/search?hl=en&q...lass+-database
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
elementwise multiplication of 2 lists of numbers harryos Python 6 09-20-2010 04:33 PM
Source of term "multiplication" in matrix multiplication William Hughes C Programming 13 03-15-2010 02:04 PM
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
List of lists of lists of lists... =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==?= Python 5 05-15-2006 11:47 AM
converting lists to strings to lists robin Python 10 04-12-2006 04:58 PM



Advertisments