Why is it possible to replace sometimes set() with {}?

前端 未结 4 550
北海茫月
北海茫月 2020-12-11 00:27

In PyCharm, when I write:

return set([(sy + ady, sx + adx)])

it says \"Function call can be replaced with set literal\" so it repl

4条回答
  •  天命终不由人
    2020-12-11 01:01

    Another example how set and {} are not interchangeable (as jonrsharpe mentioned):

    In: f = 'FH'
    
    In: set(f)
    Out: {'F', 'H'}
    
    In: {f}
    Out: {'FH'}
    

提交回复
热议问题