-1

If I have something like

class test:
  val = False

thing = test()
thing1 = test()

a = input() # In this case a would be "thing"
a.val = True

How could I get my code to read a as thing when setting the value of a.val?

1 Answers1

0

This may not be the best practice security-wise, but you can use eval:

a = eval(input())

Also to set an instance attribute you need to define your class as follows:

class test: def __init__(self): self.val = False

mklucz
  • 150
  • 6