I'm trying to make a web scraper that need cookies and headers. I defined a function that returns them and I made a main function to run everything. But it doesn't get the cookies. When I run it with  if __ name__ ==  __main: it works but if I put it in a function it doesn't.
That doesn't work:
def main(user, password):
    cookies, headers = login(user, password)
    for thread in argv[1::]:
        for photo in get_photos(thread):
            download(photo)
That does work:
if __name__ == "__main__":
    cookies, headers = login(user, password)
    for thread in argv[1::]:
        for photo in get_photos(thread):
            download(photo)
 
    