How to work with more than one python file?

2

I learned to import modules, but I do not know how to, for example, create a class in a separate file and include it in the main program, how to do that?

    
asked by anonymous 06.10.2017 / 18:16

1 answer

5

Save the file in the same folder as the original file and you can import it without any problems.

file1.py

class Classe:
    def __init__():
        ....

file2.py

from arquivo1 import Classe

obj = Classe()
......
    
06.10.2017 / 18:28