Changeset 1174 in lmdz_wrf for trunk/tools
- Timestamp:
- Oct 11, 2016, 4:25:59 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r1146 r1174 72 72 # radius_angle: Function to generate a matrix with the angle at a given point 73 73 # radius_dist: Function to generate a matrix with the distance at a given point 74 # replace_list: Function to replace a value in a given list 74 75 # same_shape: Function to check if two matrices have the same shape 75 76 # search_sec_list: Function to provide the values and indices on a list which matches a section of a string … … 9490 9491 9491 9492 return latextext 9493 9494 def replace_list(listv,oldv,newv): 9495 """ Function to replace a value in a given list 9496 listv= list of values 9497 oldv= value to replace 9498 newv= value to use 9499 >>> replace_list(range(10),3,'iii') 9500 [0, 1, 2, 'iii', 4, 5, 6, 7, 8, 9] 9501 """ 9502 fname = 'replace_list' 9503 9504 newlist = list(listv) 9505 iv = 0 9506 for vv in listv: 9507 print iv,vv,type(vv),oldv,vv == oldv 9508 if vv == oldv: newlist[iv] = newv 9509 iv = iv + 1 9510 9511 return newlist 9512 9492 9513 #quit() 9493 9514
Note: See TracChangeset
for help on using the changeset viewer.