Benjamin Peterson added the comment:
I'm disinclined to change the fix here after it's existed in this for for 10
years.
--
resolution: -> rejected
stage: -> resolved
status: open -> closed
___
Python tracker
Pranav Devarakonda 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
Karthikeyan Singaravelan added the comment:
Thanks for the patch but I feel adding type checks will add more complexity to
the code being converted and there are a lot of cases to handle. I have some
code below where running 2to3 will just wrap the keys() call to a list but with
the patch
New submission from Pranav Devarakonda :
fix_dict.py applies fixes to every instance of keys(), items() or values()
irrespective of the type of object. Since 2to3 cannot check the type of the
object, we can at least add the check to the generated code like...
d.keys() -> list(d.keys) if