0

I am trying one demo, where I am using modules there are three code files and bellow is the structure of the codes

--Main Dir 
--packages
          - __init__.py
          - Input.py 
          - Calculation.py
          - Add.py 
 -main.py  

init.py is empty

Input.py

class Input:

def __init__(self):
    print("input is initialized")

Calculation.py

import Input

class Calculator:
    def __init__(self):
        ip = Input.Input()
        print("calculator is itisilised")

Add.py

import Calculation

class Add:
    def __init__(self):
        cal = Calculation.Calculator()
        print("add class is initialsed")

main.py

from packages import Add

class main:
    def __int__(self):
        print("main is initialsed")
        objadd = Add.Add()

main_obj = main() 

but I am getting bellow Error

in Add.py    
ModuleNotFoundError: No module named 'Calculation'
ArnabGhosh
  • 35
  • 6
  • well yes, why do you assume `Calculation` to be in the path? – juanpa.arrivillaga Jun 25 '20 at 18:16
  • 1
    Does this answer your question? [How to import the class within the same directory or sub directory?](https://stackoverflow.com/questions/4142151/how-to-import-the-class-within-the-same-directory-or-sub-directory) – mkrieger1 Jun 25 '20 at 18:20

0 Answers0