Re: iterator? way of generating all possible combinations?

2006-05-31 Thread Scott David Daniels
Jim Segrave wrote: > In article <[EMAIL PROTECTED]>, > Scott David Daniels <[EMAIL PROTECTED]> wrote: >> class FileReIterable2(object): >> ... >> def __iter__(self): >> self.file.seek(0) >> for line in self.file: >> nextpos = self.file.te

Re: iterator? way of generating all possible combinations?

2006-05-31 Thread Jim Segrave
In article <[EMAIL PROTECTED]>, Scott David Daniels <[EMAIL PROTECTED]> wrote: > >This works if-and-only-if it is only in use once at a time. >If you have multiple simultaneous accesses, you need to do >something like: > > class FileReIterable2(object): > def __init__(self, file): >

Re: iterator? way of generating all possible combinations?

2006-05-31 Thread [EMAIL PROTECTED]
Scott David Daniels wrote: > [EMAIL PROTECTED] wrote: > > Scott David Daniels wrote: > >> Sorry, "re-iterables". A file re-iterable is: > >> > >> class FileReIterable(object): ... > >> def __iter__(self): > >> self.file.seek(0) > >> return iter(self.file) >

Re: iterator? way of generating all possible combinations?

2006-05-30 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > Scott David Daniels wrote: >> Sorry, "re-iterables". A file re-iterable is: >> >> class FileReIterable(object): ... >> def __iter__(self): >> self.file.seek(0) >> return iter(self.file) >> >> This works if-and-only-if it is only in

Re: iterator? way of generating all possible combinations?

2006-05-30 Thread [EMAIL PROTECTED]
Scott David Daniels wrote: > Sorry, "re-iterables". A file re-iterable is: > > class FileReIterable(object): > def __init__(self, file): > if isinstance(file, basestring): > self.file = open(file, 'rU') > else: > self.file

Re: iterator? way of generating all possible combinations?

2006-05-30 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > Scott David Daniels wrote: > >> This works with "iterables" (and produces), rather than "iterators", >> which is vital to the operation. >> >> --Scott David Daniels >> [EMAIL PROTECTED] > > Sorry, it doesn't. It works with strings. It doesn't work with file, > it does

Re: iterator? way of generating all possible combinations?

2006-05-30 Thread [EMAIL PROTECTED]
Scott David Daniels wrote: > This works with "iterables" (and produces), rather than "iterators", > which is vital to the operation. > > --Scott David Daniels > [EMAIL PROTECTED] Sorry, it doesn't. It works with strings. It doesn't work with file, it doesn't work with iterators I have created.

Re: iterator? way of generating all possible combinations?

2006-05-30 Thread [EMAIL PROTECTED]
This would only work for combinations of identical sets, and also does not seem to work with generated sets, or iterators. Forgetting dice for a moment. Say I have 3 very long files, and i want to generate the combinations of lines in the files. This provides a well known iterator for the exampl

Re: iterator? way of generating all possible combinations?

2006-05-30 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > However, none of the algo's I have checked will work with generated > sequences, or iterable classes, as posited in my first post. > > While appropriate to the current domain, ie dice. What if you want > combinations of extrememely large lists, say 3 sets of 10 mil item

Re: iterator? way of generating all possible combinations?

2006-05-30 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > > > Well thanks for the mathematical restatement of my problem. I had > forgotten the proper terms. Searching on those terms generates some > interesting results. > > However, none of the algo's I have checked will work with generated > sequences, or iterable classe

Re: iterator? way of generating all possible combinations?

2006-05-30 Thread [EMAIL PROTECTED]
Well thanks for the mathematical restatement of my problem. I had forgotten the proper terms. Searching on those terms generates some interesting results. However, none of the algo's I have checked will work with generated sequences, or iterable classes, as posited in my first post. While app

Re: iterator? way of generating all possible combinations?

2006-05-27 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Terry Reedy wrote: > >> >> Are the dice identical or distinguishable (marked). In other words, >> with 2 >> dice, is 1,2 the same as 2,1 or different? Note that in most dice >> games, >> such as craps, the dice are not distinguis

Re: iterator? way of generating all possible combinations?

2006-05-26 Thread [EMAIL PROTECTED]
hmmm, just needed better search words, thanks :) -- http://mail.python.org/mailman/listinfo/python-list

Re: iterator? way of generating all possible combinations?

2006-05-26 Thread [EMAIL PROTECTED]
Terry Reedy wrote: > > Are the dice identical or distinguishable (marked). In other words, with 2 > dice, is 1,2 the same as 2,1 or different? Note that in most dice games, > such as craps, the dice are not distinguished, but probability calculations > must treast them as if they were to get th

Re: iterator? way of generating all possible combinations?

2006-05-26 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ok, this is really irritating me. I'm sure there are different ways of > doing this - I'm interested in the algo, not the practical solution, > I'm more trying to play with iterators and recursion. I want to create > a program that g

Re: iterator? way of generating all possible combinations?

2006-05-26 Thread Raymond Hettinger
[EMAIL PROTECTED] wrote: > Ok, this is really irritating me. I'm sure there are different ways of > doing this - I'm interested in the algo, not the practical solution, > I'm more trying to play with iterators and recursion. I want to create > a program that generates every possible combination

iterator? way of generating all possible combinations?

2006-05-26 Thread [EMAIL PROTECTED]
Ok, this is really irritating me. I'm sure there are different ways of doing this - I'm interested in the algo, not the practical solution, I'm more trying to play with iterators and recursion. I want to create a program that generates every possible combination of a set of a n dice, with s sides