On Mon, Sep 12, 2016 at 9:14 PM, Daiyue Weng <daiyuew...@gmail.com> wrote: > Hi, I found that when I tried to make an equality test on empty like, > > if errors == []: > > PyCharm always warns me, > > Expression can be simplified. > > I am wondering what's wrong and how to fix this? >
If you know that 'errors' is always going to be a list, you can check for emptiness thus: if not errors: PyCharm recommends this syntax rather than the comparison with a newly-created empty list. Your code has to actually construct and dispose of a list, just for the comparison. ChrisA -- https://mail.python.org/mailman/listinfo/python-list