-->

Sunday, May 19, 2013

Lists


Lists are ordered collections of items: they are the arrays of python but better shaped. They are mutable ( they can be changed in place)

good practices: 
-always use append
- remember that operations like sort change the list object in-place which means that : 

given : 
l.sort()
you dont need to copy it into another list

# super simple way to deal with  list ( array ) of values


tpr1=[]                                                                                                       
fpr1=[]                                                                                                       
for th in arange(1,10,1):                 
    tpr1.append(th)                                                                       
    fpr1.append(th)                                                                       

but if you want performances use dictionaries:

tpr1={}
c=0
for th in arange(1,10,1):                 
   tpr1[c]=th
   c+=1

No comments:

Post a Comment