test.py 349 B

12345678910111213141516171819202122
  1. import sys
  2. class Test(object):
  3. def __init__(self):
  4. self._msg = "haha"
  5. def msg(self):
  6. return self._msg
  7. def classe(txt):
  8. try:
  9. retour = getattr(sys.modules[__name__], txt)
  10. except:
  11. retour = None
  12. return retour
  13. t = "Test"
  14. tt = classe(t)()
  15. print tt.msg()