0

I need to use the arg to call an other function inside another module

Thank you!

def func (arg):
   if module.session.query(module.arg).filter(module.arg.id == id).one():
   #some other staff
Dmitriy Grankin
  • 568
  • 9
  • 21
  • you should use the [getattr](https://docs.python.org/3/library/functions.html#getattr) function – 0e1val Feb 02 '19 at 13:35

1 Answers1

0

use the getattr built-in function:

def func (arg):
    if module.session.query(getattr(module, arg)).filter(getattr(module, arg).id == id).one():
0e1val
  • 481
  • 3
  • 6