[FIXED] python call module other script

Issue

I want to make a module script like module.py and I want to call these modules in other script files. How can I do that?

module.py

    import time
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    import os
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.common.exceptions import TimeoutException


    opt=Options()
    opt.add_experimental_option("excludeSwitches", ["enable-automation"])


    driver = webdriver.Chrome(options=opt)

    insta = 'https://www.instagram.com/'

    driver.get(insta)

    delay = 3

and main.py

import module


........ my code


Solution

from module import <thing to import>

You mean like this?

You can do

from module import opt, driver, insta, delay

And anything else you need.

If you want to import everything do from module import *



Answered By - topal
Answer Checked By - David Goodson (Python.Easybugfix Volunteer)

Related Posts

Post a Comment