Created attachment 1174 [details] Non-obfuscated code for the example. It does not work, specifically, if the comprehension statement is put in a function (outside functions it works just fine). Example: > input_lst = ['This', 'sentence', 'is', 'false'] > > def capitalize_str(string): > return string.capitalize() > > def do_stuff(lst): > _lst = [capitalize_str(elem) for elem in lst] > _set = {capitalize_str(elem) for elem in lst} > _dict = {elem: capitalize_str(elem) for elem in lst} > return _lst, _set, _dict > > res = do_stuff(input_lst) > > _lst = [capitalize_str(elem) for elem in input_lst] > _set = {capitalize_str(elem) for elem in input_lst} > _dict = {elem: capitalize_str(elem) for elem in input_lst} Is obfuscated to: > iIiii1i111i1I = [ 'This' , 'sentence' , 'is' , 'false' ] > if 5 - 5: i11i1 > def II1Ii ( string ) : > return string . capitalize ( ) > if 98 - 98: OooOoo * oO0Oo0O > def I1I ( lst ) : > ooo0oOoooOOO0 = [ capitalize_str ( elem ) for elem in lst ] > oOo0O00 = { capitalize_str ( elem ) for elem in lst } > i1iiIII111 = { elem : capitalize_str ( elem ) for elem in lst } > return ooo0oOoooOOO0 , oOo0O00 , i1iiIII111 > if 29 - 29: iI + o00Oo - OOoOoo000O00 * Oo0Oo - ii1I1iII1I1I . i1I1IiIIiIi1 > oo0O000ooO = I1I ( iIiii1i111i1I ) > if 98 - 98: IiiIIiii1 % iIi1ii1I1iI11 > ooo0oOoooOOO0 = [ II1Ii ( elem ) for elem in iIiii1i111i1I ] > oOo0O00 = { II1Ii ( elem ) for elem in iIiii1i111i1I } > i1iiIII111 = { elem : II1Ii ( elem ) for elem in iIiii1i111i1I } > # dd678faae9ac167bc83abf78e5cb2f3f0688d3a3 Where you can see that the function capitalize_str() has not been replaced in comprehensions in side the function.
Also note that the name of the iterator variable ("elem") should also be obfuscated.