[Tutor] trying to split or rpartition the contents of a list

Albert-Jan Roskam fomcl at yahoo.com
Wed May 22 10:06:09 CEST 2013


>

>forobjectinobjects:sorted(set(object.split('_',1)[0]))cmds.menuItem(label =object,parent ="objectMenu")


"sorted" returns the sorted list but you don't assign anything to it. You can either assign it to a variable, or use the .sort method instead. Also, you don't need to specify the maxsplit argument (1) in .split. Also, you used 'object' as a loop index but this is a reserved word. Why not use the more descriptive "for filename in filenames"?


More information about the Tutor mailing list