python get object attribute by string

Do you want to know the information regarding “python get object attribute by string”. If yes, you’re in the correct post.

python get object attribute by string

x = getattr(t, 'attr1')
setattr(t, 'attr1', 21)

Final Thoughts

I hope this post helps you to know about “python get object attribute by string”. If you have any questions regarding this post please let us know via the comment section. Share this article with your friends & family via social networks.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coder Diksha. Here, I post about programming to help developers.

Share on:

Leave a Comment