Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-29 Thread ZUXOXUS
2010/7/28 Dave Angel > ZUXOXUS wrote: > >> >> >> My doubt now is whether I can change the way python show the combinations. >> >> I mean, here's what python actually does: >> >> >> >>> for prod in itertools.product('abc', repeat=3): > > print(prod) >> >> ('a', 'a', 'a') >> ('a', 'a'

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-28 Thread Dave Angel
ZUXOXUS wrote: My doubt now is whether I can change the way python show the combinations. I mean, here's what python actually does: for prod in itertools.product('abc', repeat=3): print(prod) ('a', 'a', 'a') ('a', 'a', 'b') ('a', 'a', 'c') ('a', 'b', 'a') ('a', 'b', 'b') ('a', '

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-28 Thread ZUXOXUS
> > 2010/7/28 Dave Angel > > > Your latest version gets the product of two. But if you want an arbitrary >> number, instead of repeating the iterable ('ABC' in your case), you can >> use >> a repeat count. That's presumably what you were trying to do in your >> earlier incantation. But you for

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-28 Thread Dave Angel
ZUXOXUS wrote: 2010/7/28 Dave Angel Your latest version gets the product of two. But if you want an arbitrary number, instead of repeating the iterable ('ABC' in your case), you can use a repeat count. That's presumably what you were trying to do in your earlier incantation. But you forgot

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-28 Thread ZUXOXUS
2010/7/28 Dave Angel > > > ZUXOXUS wrote: > >> Oh, I think i got it: >> >> >> >>> for prod in itertools.product('ABC', 'ABC'): > > print(prod) >> >> ('A', 'A') >> ('A', 'B') >> ('A', 'C') >> ('B', 'A') >> ('B', 'B') >> ('B', 'C') >> ('C', 'A') >> ('C', 'B') >> ('C', 'C') >> >> Thank

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread Dave Angel
ZUXOXUS wrote: Oh, I think i got it: for prod in itertools.product('ABC', 'ABC'): print(prod) ('A', 'A') ('A', 'B') ('A', 'C') ('B', 'A') ('B', 'B') ('B', 'C') ('C', 'A') ('C', 'B') ('C', 'C') Thank you very much!! 2010/7/28 ZUXOXUS You're top-posting, which loses all the

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread ZUXOXUS
Oh, I think i got it: >>> for prod in itertools.product('ABC', 'ABC'): print(prod) ('A', 'A') ('A', 'B') ('A', 'C') ('B', 'A') ('B', 'B') ('B', 'C') ('C', 'A') ('C', 'B') ('C', 'C') Thank you very much!! 2010/7/28 ZUXOXUS > Mac, > > this is what I get: > > >>> for prod in itertools.product('A

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread ZUXOXUS
Mac, this is what I get: >>> for prod in itertools.product('ABC', 2): print(prod) Traceback (most recent call last): File "", line 1, in for prod in itertools.product('ABC', 2): TypeError: 'int' object is not iterable hmm, what might be that 'int' object? 2? 2010/7/28 ZUXOXUS > Shar

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread ZUXOXUS
Sharp thanks, but: I try to reproduce the example from the table, but: >>> import itertools >>> combinations('ABC', 2) Traceback (most recent call last): File "", line 1, in combinations('ABC', 2) NameError: name 'combinations' is not defined >>> If im not mistaken, it should return AB, A

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread Mac Ryan
On Tue, 2010-07-27 at 23:31 +0100, Mark Lawrence wrote: > On 27/07/2010 23:20, ZUXOXUS wrote: > > Hi all pythoners > > > > I've got a probably easy to answer question. > > > > Say I've got a collections of strings, e.g.: 'man', 'bat', 'super', 'ultra'. > > > > They are in a list, or in a sequence o

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread Mark Lawrence
On 27/07/2010 23:20, ZUXOXUS wrote: Hi all pythoners I've got a probably easy to answer question. Say I've got a collections of strings, e.g.: 'man', 'bat', 'super', 'ultra'. They are in a list, or in a sequence or whatever, say a bag of words And now I want to know how many couples I can do

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread Nick Raptis
On 07/28/2010 01:20 AM, ZUXOXUS wrote: Hi all pythoners I've got a probably easy to answer question. Say I've got a collections of strings, e.g.: 'man', 'bat', 'super', 'ultra'. They are in a list, or in a sequence or whatever, say a bag of words And now I want to know how many couples I ca

[Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread ZUXOXUS
Hi all pythoners I've got a probably easy to answer question. Say I've got a collections of strings, e.g.: 'man', 'bat', 'super', 'ultra'. They are in a list, or in a sequence or whatever, say a bag of words And now I want to know how many couples I can do with them, and I want the program to s