[Tutor] a shorter way to write this

Smith, Jeff jsmith at medplus.com
Fri Mar 25 20:26:01 CET 2005

For all the talk of Python only having one way to do something which is
why it's so much better than Perl, I've counted about 10 ways to do this


-----Original Message-----
From: Sean Perry [mailto:shaleh at speakeasy.net] 
Sent: Friday, March 25, 2005 2:20 PM
To: Tutor Tutor
Subject: Re: [Tutor] a shorter way to write this

jrlen balane wrote:
> basically, i'm going to create a list with 96 members but with only 
> one value:
> list1[1,1,1,1...,1]
> is there a shorter way to write this one???

def generateN(n):
     while 1:
         yield n

I'll leave the actual list creation up to you (-:
Tutor maillist  -  Tutor at python.org

More information about the Tutor mailing list