I'm pretty new to Python and, in writing an app, have ended up with a structure that's a bit of a mess. The example below should illustrate what I'm trying to do. The issue is that I can't ca开发者_JS百科ll the login method from common.py because it is only defined in website1.py or website2.py.
Module common.py
class Browser():
    def load_page():
        Login.login()
Module website1.py import common.py
class Login:
    @staticmethod        
    def login():
        #code to login to this website 1
Module website2.py import common.py
@staticmethod
class Login:
    def login():
        #code to login to website 2
Any thoughts on how to restructure this would be appreciated.
First of all, why static methods? You could just do def login at the global level.
Second of all, you could pass a class reference to the Browser class. (or a module reference if you take my first suggestion)
class Browser(object):
    def __init__(self, loginCls):
        self.loginCls = loginCls
    def login_page(self):
        self.loginCls.login()
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论