Pranav Devarakonda <devarakondapra...@yahoo.com> added the comment:

Thank you very much for pointing out some helpful things,  Karthikeyan. 

>True if 1 in list(a.keys()) if type(a) == dict else a.keys() else False

True that the fixer would return a syntax error in this case. I missed adding a 
pair of parenthesis to the whole if statement. I mean

True if 1 in (list(a.keys()) if type(a) == dict else  a.keys()) else False

is valid code. So adding parenthesis would solve the problem as I did in the 
updated patch I uploaded.

I don't see this updated fixer returning errors in other cases like nested if 
conditions or list comprehensions, since the fixer would convert the respective 
function calls of dict objects into separate statements, would not interfere 
with other if statements(or any other statements for that matter) and set the 
order of precedence appropriately.

Please do point out if there any other cases I missed. 

I know this is a less pythonic but is more accurate :) Thanks.

----------
Added file: https://bugs.python.org/file47871/fix_dict.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34978>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to