0

I have below situation:

class data:
    one = "FIRST"
    two = "SECOND"
    three = "THIRD"  
class bandwidth:
    pkgone = "TINY"
    pkgtwo = "MEDIUM"
    pkgthree = "ABOVE MEDIUM"   

analysis = <some slicing from a dict> 

Lets say:

print(analysis)

one

Now I want to print value of a class variable which which has variable one. So output should be like:

output = logic here

print(output)

FIRST

How should I achieve this?

Community
  • 1
  • 1

1 Answers1

0

Use getattr

>>> getattr(data, 'one')
'FIRST'
pacholik
  • 8,607
  • 9
  • 43
  • 55