Posts

Showing posts from September, 2017

Python: Removing matched items from a list

list1= [12, 50, -20, -120, 14.5, 3, 6, -120]; list2= [3, -200, 50, -120]; list3A= filter(lambda x: x not in list2, list1); #[12, -20, 14.5, 6] list3B= list(set(list1)-set(list2)); #[14.5, -20, 12, 6]

Maya User scripts path (Win/MAC)

def _getMayaScriptFolder(): import os; import platform; dspath=False;f=None;div=":"; spaths=os.environ['MAYA_SCRIPT_PATH']; if platform.system()=="Windows":div=";"; paths=spaths.split(div); for i in range(0,len(paths)): p=paths[i]; brk=p.split("/"); num=len(brk); if num>2 and brk[1]=="Users": for j in range(0,num): if brk[j]=="scripts": if f==None:f=j;spath=p; elif j<f:f=j;spath=p; return(spath); print _getMayaScriptFolder();