Which is better in python, del or delattr?

后端 未结 8 1898
既然无缘
既然无缘 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:34

    If you think delattr is more explicit, then why not used getattr all the time rather than object.attr?

    As for under the hood... your guess is as good as mine. If not significantly better.

提交回复
热议问题