[Maya-Python] Unable to get the difference between 2 lists

2014-11-20 Thread likage
I am trying to find the difference between two lists - charLs and rigLs but as I tried to use the list and set methods as I found online, it is giving me very different results. In the example below, I should be seeing *female01* and *elderly01* in the diff1 results but yet I am getting *male01

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread Mark Jackson
Think what you're probably after is the difference call in sets, ie, return the difference between the two sets diff2 = list(set(rigLs)^set(charLs)) What the minus sign does is a return elements in the first arg that aren't in the second, where as the ^ sign returns the actual difference. That sa

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread likage
Hey Mark, Thanks for getting back to me. I am still not getting the results, seems to be the unicode error as I am appending the items into list. It works unless i took out the u in each of the list.. Is there any ways that I can take out the unicode or do I need to do some more splittings? On

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread Justin Israel
I'm not getting any issues getting the different even with sets of mixed unicode and ascii objects. Can you give a specific example that can reproduce your error? Also this can be a little bit easier to read: a = set([u'male01', u'female01', u'elderly01']) b = set([u'male01']) a.difference(b)# {u

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread Marcus Ottosson
If you can post an example where you show us the actual content of the two list you are comparing, it will be much easier to help you find what might be wrong. Something like: a = {1, 2, 3} b = {2, 3, 4}print a - b # Remove items from a that exist in b# 1print b - a # Remove items in b that exi

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread Marcus Ottosson
Jinx, buy me a coke On 21 November 2014 08:20, Justin Israel wrote: > I'm not getting any issues getting the different even with sets of mixed > unicode and ascii objects. Can you give a specific example that can > reproduce your error? > > Also this can be a little bit easier to read: > > a = s

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread likage
I took back what I mentioned about the unicode. It is somewhat hard for me to give an example, as publishedRef is an in-house module. Tried out the method supplied by Justin, it is still printing [u'male01', u'female01', u'elderly01'] which is the same results as diff2 - in my first post... I

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread Justin Israel
Forget the Maya specific parts. If it is related to the sets then you should be able to reproduce it with generic Python. If you can't, then it is some other mistake or mishandling going on in your code. On Fri, 21 Nov 2014 9:35 PM likage wrote: > I took back what I mentioned about the unicode.

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread likage
By doing a simple set example using generic Python, it is working with no issues. I am achieving the results that I had wanted see. So I guess this may be something due to the Maya handling part.. I thought if appending the name, it will not affect anything much -- You received this message be

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread likage
Adding on, seems to be an issue around the listRelatives part in my case On Friday, November 21, 2014 5:17:15 PM UTC+8, likage wrote: > > By doing a simple set example using generic Python, it is working with no > issues. I am achieving the results that I had wanted see. > > So I guess this may

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread Eduardo Grana
Hey Mark, Be aware that when you do set(list) you discard the duplicates on the list, so you may be comparing different things... by the way, aren't sets deprecated? Cheers! Eduardo On Fri, Nov 21, 2014 at 5:00 AM, Mark Jackson wrote: > Think what you're probably after is the difference call in

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread Marcus Ottosson
aren’t sets deprecated? Certainly not! You may be thinking of the top of the link I posted above as reference. That is in regards to the “sets” module, which looks to have been merged into top-level Python functionality. Quite the opposite of deprecation. :) ​ On 21 November 2014 12:50, Eduardo G

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread Eduardo Grana
Sorry, my bad... Don't remember quite well why when i used it in a previous python version it gave me a deprecation warning... On Fri, Nov 21, 2014 at 11:09 AM, Marcus Ottosson wrote: > aren’t sets deprecated? > > Certainly not! You may be thinking of the top of the link I posted above > as refe

Re: [Maya-Python] Unable to get the difference between 2 lists

2014-11-21 Thread Paul Molodowitch
Question - are your results that are inside of rigLs truly the direct result of a call to cmds.listRelatives()? Are you sure that the objects inside of rigLs are truly strings (or unicode)? I ask because I've noticed that in maya 2015, a repr was added to MObjects... which would be nice, except t