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 call 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 loginat the global level.Second of all, you could pass a class reference to the
Browserclass. (or a module reference if you take my first suggestion)