In article <515e582f-ed17-4d4e-9872-f07f1fda6...@googlegroups.com>, Jean Dupont <jeandupont...@gmail.com> wrote:
> I'm looking for an efficient method to produce rows of tables like this: > > for base 2 > 0 0 0 0 > 0 0 0 1 > 0 0 1 0 > 0 0 1 1 > 0 1 0 0 > . > . > . > 1 1 1 1 > > for base 3 > 0 0 0 0 0 0 > 0 0 0 0 0 1 > 0 0 0 0 0 2 > 0 0 0 0 1 0 > 0 0 0 0 1 1 > 0 0 0 0 1 2 > . > . > 2 2 2 2 2 2 This sounds like a homework problem :-) > As you can see the rows are always twice the size of the base Why? > I _don't_ need to have all rows available together in one array which would > become too large for higher value number bases. It's sufficient to produce > one row after the other, as I will do further data manipulation on such a row > immediately. What I get out of that is that you don't want to just print them, you want to have some function which returns all the generated rows in order. The way to do that is with the yield statement. Take a look at https://wiki.python.org/moin/Generators for some discussion on how that works. Actually, http://stackoverflow.com/questions/231767/ looks like an even better discussion. Does that help you any? -- https://mail.python.org/mailman/listinfo/python-list