Your explanation dos not make so much sense,so i make a example.
C:\Python36\sudoku_folder\
|-- __init__.py
|-- bar.py
game\
|-- __init__.py
|-- sudoku.py
__init__.py
files are blank,they help Python navigate the file tree.
# bar.py
def foo():
return 42
if __name__ == '__main__':
print(foo())
# sudoku.py
class Sudoku:
def __init__(self, number):
self.number = number
def result(self, last_number):
return last_number + self.number
if __name__ == '__main__':
play = Sudoku(100)
print(play.result(50))
Now can i test my
package
.
C:\
λ ptpython
>>> from sudoku_folder.game import sudoku
>>> play = sudoku.Sudoku(555) # Now do i access Sudoku class
>>> play.result(100)
655
>>> # Assess the lonely foo() function
>>> from sudoku_folder import bar
>>> bar.foo()
42
Try to understand the basic how folder and files work in a package.
Can also edit
__init__.py
to shorten import statement,but that do i not take now.