Which is better in python, del or delattr?

后端 未结 8 1903
既然无缘
既然无缘 2020-12-12 11:08

This may be silly, but it\'s been nagging the back of my brain for a while.

Python gives us two built-in ways to delete attributes from objects, the del

8条回答
  •  悲哀的现实
    2020-12-12 11:25

    Unquestionably the former. In my view this is like asking whether foo.bar is better than getattr(foo, "bar"), and I don't think anyone is asking that question :)

提交回复
热议问题