On Thu, 4 Mar 2010 12:07:48 +0100
Masklinn
In fact, in your case I think supporting slicing/islicing would make far more sense than the solution you've elected)
Actually my Powers type should be "sliceable".
tripleCubes = [sq for sq in islice(cubes, 6, 16) if sq%3 == 0]
Right, but this pattern only replaces cubes(6, 16) by islice(cubes, 6, 16): tripleCubes = [sq for sq in cubes(6, 16) if sq%3 == 0] Or do I overlook a relevant point? I guess the proper (and pythonic?) solution would be to implement __getitem__ so as to be able to write: tripleCubes = [sq for sq in cubes[6:17] if sq%3 == 0] Does the following match your idea? def __getitem__(self, ranj): self.n , self.max = ranj.start-1 , ranj.stop-1 return self Denis -- ________________________________ la vita e estrany spir.wikidot.com