, , append 。
#pylist_test.py
class Test:
i = 0
def __init__(self):
pass
def sayhello(self):
print 'hello'+str(self.i)
Test.i = self.i+1
def geti(self):
print self.i
def __del__(self):
print 'destruct'+str(self.i)
def main():
li = list()
j = int()
j = 0
seq = (1,2,3,4,5)
#print len(seq)
for i in seq:
for i in seq:
li.append(Test())
li[j].sayhello()
j = j + 1
print "come here 01!"
li[i-1].geti()
print len(li)
print "come here o2!"
main()
#print len(li)
print "come here 03!"
#Tuple To List
#>>> li = list((1,2))
#[1,2]
#List To Tuple
#>>> tu = tuple([1,2])
#(1,2)
#we can declare a specific type variable obviously
#size = int()
#size = 1
#print type(size),size
#size = 'test'
#print type(size),size
#list_test = list()
#print type(list_test)
#t1 = Test()
#t2 = Test()
#t3 = Test()
#list_test.append(t1)
#list_test.append(t2)
#list_test.append(t3)
#list_test[0].sayhello()
#list_test[1].sayhello()
#list_test[2].sayhello()
#list can be nested in Python
#list_2 = list()
#list_2.append(list_test)
#list_2[0][0].sayhello()
#list_2[0][1].sayhello()
#list_2[0][2].sayhello()