0

I have tried to access to object variables dynamically. The question is how to access with variables to object properties. For example:

    >>> my_obj = x_class()
    >>> property = "name"
    >>> my_obj.property = "Rick"
    >>> my_obj.name
    "Rick"

I have found some answers but in JS not in python Thanks in advance

Onyx
  • 3
  • 4
  • [This](https://chase-seibert.github.io/blog/2013/04/12/getattr-setattr.html) gives a detailed explanation to what you're looking for. – Vishakha Lall Jan 24 '20 at 05:17
  • i have tried with `setattr()` but i does not change the variable, when i ask for it, retrieves the past value – Onyx Jan 24 '20 at 05:21
  • My bad i was trying with `setattr(obj, "property", value)` instead of `setattr(obj, property, value)`, thanks to all – Onyx Jan 24 '20 at 05:28

0 Answers0