python: Two modules and classes with the same name under different packages

You want to import the User modules in the package __init__.py files to make them available as attributes.

So in both Helper/__init_.py and Controller/__init__.py add:

from . import User

This makes the module an attribute of the package and you can now refer to it as such.

Alternatively, you’d have to import the modules themselves in full:

import ShutterDeck.Controller.User
import ShutterDeck.Helper.User

u1=ShutterDeck.Controller.User.User()
u2=ShutterDeck.Helper.User.User()

so refer to them with their full names.

Another option is to rename the imported name with as:

from ShutterDeck.Controller import User as ControllerUser
from ShutterDeck.Helper import User as HelperUser

u1 = ControllerUser.User()
u2 = HelperUser.User()

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)