Re: [Tutor] a shorter way to write this

2005-03-26 Thread John Fouhy
Kent Johnson wrote: jrlen balane wrote: basically, i'm going to create a list with 96 members but with only one value: is there a shorter way to write this one??? [1] * 96 Just a note on this --- This will work fine for immutable types (such as integers or strings). But you can get into trouble i

Re: [Tutor] a shorter way to write this

2005-03-25 Thread Sean Perry
Smith, Jeff wrote: 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 :-) Knowing you said this at least half in jest, I still feel the need to comment. In any programming language, you have flexibility

RE: [Tutor] a shorter way to write this

2005-03-25 Thread Danny Yoo
> 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??? Hi Jrlen Balana, I wanted to ask: why do we want to make a list of 96 members, with the same value? This s

RE: [Tutor] a shorter way to write this

2005-03-25 Thread Smith, Jeff
ubject: 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

Re: [Tutor] a shorter way to write this

2005-03-25 Thread Sean Perry
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 (-: ___

Re: [Tutor] a shorter way to write this

2005-03-25 Thread Kent Johnson
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??? [1] * 96 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tut

RE: [Tutor] a shorter way to write this

2005-03-25 Thread Ryan Davis
A comprehension and range? # >>> list1 = [1 for x in range(0,96)] >>> len(list1) 96 # Thanks, Ryan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of jrlen balane Sent: Friday, March 25, 2005 2:03 PM To: Tutor Tutor Subject: [Tutor] a sh

Re: [Tutor] a shorter way to write this

2005-03-25 Thread jrlen balane
a, so thats the way to do it, a list comprehension, thanks for the info... On Fri, 25 Mar 2005 14:10:41 -0500, Gabriel Farrell <[EMAIL PROTECTED]> wrote: > how about > > manyones = [ 1 for x in range(96) ] > > > On Sat, Mar 26, 2005 at 03:02:34AM +0800, jrlen balane wrote: > > basically,

Re: [Tutor] a shorter way to write this

2005-03-25 Thread Gabriel Farrell
how about manyones = [ 1 for x in range(96) ] On Sat, Mar 26, 2005 at 03:02:34AM +0800, 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??? > ___

Re: [Tutor] a shorter way to write this

2005-03-25 Thread Peter Markowsky
Hi, On Mar 25, 2005, at 2:02 PM, 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] You might want to use a list comprehension like: [1 for i in range(96)] -Pete ___ Tutor maillist -

[Tutor] a shorter way to write this

2005-03-25 Thread jrlen balane
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??? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor