-3

How can I use return value in another file?

File1:
    def system(self):
        # do something
        return: value_1, value_2

File2:
    def to_do(self):
       # do something
       result = file_location.file1(value_1, value2)

Is this correct way?

tafaust
  • 1,457
  • 16
  • 32
Plane
  • 1
  • 2

1 Answers1

1

You should import the specific method of File1.py in File2.py that you want to use. Also note that python can return multiple values and how I have stored them in File2.py.

File1.py

    def system(self):
        # do something
        return value_1, value_2

File2.py

    from File1 import system
    def to_do(self):
       # do something
       result1, result2 = system(value_1, value2)
MSS
  • 3,306
  • 1
  • 19
  • 50