I have a question, but I can't find it well even if I search for it, so I'm asking
If the class foo has an attribute called bar,
tmp = foo()
tmp.bar
You can approach it like this.
If so
a = when 'bar'
Can I access the property of foo.bar with a? The question is a bit difficult, but I'd appreciate it if you could answer it.
python python3
Many modern languages and environments are applying under the name of RTTI, reflection, etc.
class Abc:
def __init__(self):
self.a = 5
abc = Abc()
getattr(abc, 'a')
5
© 2024 OneMinuteCode. All rights reserved.