Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Oct 19 05:30:46 CEST 2008

On Sat, 18 Oct 2008 03:52:51 -0700, Gandalf wrote:

> I was hopping to describe it with only one command. most of the
> languages I know use this.
> It seems weird to me their is no such thing in python. it's not that I
> can't fined a solution it's all about saving code

It shouldn't be about saving code. There's no shortage of code so that we 
have to conserve it. But there is a shortage of time and effort, so 
making your code easy to read and easy to maintain is far more important.

for x in (2**i for i in xrange(10)):
    print x

will also print 1, 2, 4, 8, ... up to 1000.


More information about the Python-list mailing list