There is a module.py file with the following content:

 class Calc(): @staticmethod def plus(a, b): return a + b @staticmethod def minus(a, b): return a - b 

Can I import in the file with the name main.py using import not the entire Calc class, but only one of its functions, for example, plus()

  • one
    There is an alternative: from module import Calc plus = Calc.plus , but I would like to immediately name the plus() function. - Don2Quixote 8:08 pm

1 answer 1

 class Calc: @staticmethod def plus(a, b): return a + b @staticmethod def minus(a, b): return a - b plus = Calc.plus minus = Calc.minus 

For import: from module import plus, minus