There's a website I would like to login to on two different accounts and create two separate persistent HTTP connections. The only way I know how to do this is to have a separate login function twice but that would seem kind of redundant so I just made the function login(). But now I would like to somehow re-use the same login function to create multiple persistent HTTP sessions in my other functions but it goes out of scope.
def login(username, password):
requests.post('example.com', data=payload)
def website1():
login("matthew", "qwerty")
session = requests.session()
def website2():
login("matthew2", "qwerty2")
session = requests.session()