i have a python class that is defined using __slots__
, like so:
class TheClass:
__slots__=['foo','bar']
I would like to sets it values by name, like so
the_object=TheClass()
for x in ['foo','bar']:
the_object[x]=x+x
is that possible?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.