Re: [Tutor] A shorter way to initialize a list?

2011-12-13 Thread Alan Gauld
On 13/12/11 20:39, Kaixi Luo wrote: I want to create a list of lists of lists (listB) from a list of lists (listA). Below there's a snippet of my code: listA = [[] for i in range(9)] listB = [[] for i in range(3)] So list A containds 9 empty lists And list B contains 3 empty lists count = 0

Re: [Tutor] A shorter way to initialize a list?

2011-12-13 Thread Emile van Sebille
On 12/13/2011 3:26 PM Kaixi Luo said... Uh, sorry. I made some very bad typos there. It should be: listA = [[] for i in range(9)] # some code here... listB = [[] for i in range(3)] count = 0 for i in range(3): for j in range(3): listB[i].append(listA[count]) count+=1

[Tutor] Fwd: A shorter way to initialize a list?

2011-12-13 Thread Rich Lovely
Forgot to reply all... -- Forwarded message -- From: Rich Lovely Date: 13 December 2011 23:17 Subject: Re: [Tutor] A shorter way to initialize a list? To: Kaixi Luo On 13 December 2011 20:39, Kaixi Luo wrote: > Hello, > > I want to create a list of lists of lists (listB) from

Re: [Tutor] A shorter way to initialize a list?

2011-12-13 Thread Kaixi Luo
On Tue, Dec 13, 2011 at 10:09 PM, Emile van Sebille wrote: > On 12/13/2011 12:39 PM Kaixi Luo said... > > Hello, >> >> I want to create a list of lists of lists (listB) from a list of lists >> (listA). Below there's a snippet of my code: >> >> list1 = [[] for i in range(9)] >> > > Should this be

Re: [Tutor] A shorter way to initialize a list?

2011-12-13 Thread Steven D'Aprano
Kaixi Luo wrote: Hello, I want to create a list of lists of lists (listB) from a list of lists (listA). Below there's a snippet of my code: list1 = [[] for i in range(9)] # some code here... listA = [[] for i in range(3)] count = 0 for i in range(3): for j in range(3): listB[i].ap

Re: [Tutor] A shorter way to initialize a list?

2011-12-13 Thread Prasad, Ramit
From: tutor-bounces+ramit.prasad=jpmorgan@python.org [mailto:tutor-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of Kaixi Luo Sent: Tuesday, December 13, 2011 2:39 PM To: tutor@python.org Subject: [Tutor] A shorter way to initialize a list? Hello, I want to create a list of lists

Re: [Tutor] A shorter way to initialize a list?

2011-12-13 Thread Emile van Sebille
On 12/13/2011 12:39 PM Kaixi Luo said... Hello, I want to create a list of lists of lists (listB) from a list of lists (listA). Below there's a snippet of my code: list1 = [[] for i in range(9)] Should this be listB? # some code here... listA = [[] for i in range(3)] count = 0 for i in ra

[Tutor] A shorter way to initialize a list?

2011-12-13 Thread Kaixi Luo
Hello, I want to create a list of lists of lists (listB) from a list of lists (listA). Below there's a snippet of my code: list1 = [[] for i in range(9)] # some code here... listA = [[] for i in range(3)] count = 0 for i in range(3): for j in range(3): listB[i].append(listA[count])

Re: [Tutor] timedelta, difference calculation

2011-12-13 Thread Timo
Op 12-12-11 20:46, rail shafigulin schreef: i found something interesting during the timedate difference calculation import datetime import time def main(): mydatetime = datetime.datetime.now() time.sleep(1) mydatetime2 = datetime.datetime.now() diff = mydatetime - mydatetime2 Lie Ryan