Python class inclusion wrong behaviour
Question: I have into my main.py

    
    
    from modules import controller
    ctrl = controller
    help(ctrl)
    print(ctrl.div(5,2))
    

and the controllor.py is:

    
    
    class controller:
        def div(self, x, y): 
            return x // y
    

when I run my main I got the error:

    
    
    Traceback (most recent call last):
      File "...\main.py", line 8, in ?
        print(ctrl.div(5,2))
    AttributeError: 'module' object has no attribute 'div'
    

WHat is wrong?


Answer: This is very confusing as shown.

When you say

    
    
    from modules import controller
    

You're making the claim that you have a module with a filename of
`modules.py`.

OR

You're making the claim that you have a package named `modules`. This
directory has an `__init__.py` file and a module with a filename of
`controller.py`

You should clarify this to be precise. It looks like you have mis-named your
files and modules in the the example code posted here.

When you say

    
    
    from modules import controller
    

That creates a _module_ (not a class) named `controller`.

When you say

    
    
    ctrl = controller
    

That creates another name for the `controller` _module_ , `ctrl`.

At no time to you reference the class (`controller.controller`). At no time
did you create an instance of the class (`controller.controller()`).

