What does it mean for an object to be unscriptable?

青春壹個敷衍的年華 提交于 2019-12-04 00:35:58

The error is "unSUBscriptable". Your user_profile object isn't a dictionary. Use user_profile.beta, not user_profile['beta'].

Alternatively, you can use a string with getattr:

getattr(user_profile, 'beta', False)

False is the default value; which, in your case would work with checking if the value is set or not. I found this very helpful, so I thought I would post this solution, even though the question was asked years ago. :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!