Thursday, February 14, 2019

py0009 : How to Declare Variable and Use variable in same file of Other file

Assume that i have two files in my project first is "__init__.py" another one is "configuration.py" and i am using config file for different type of parameters which needs to change timely. The case is declared variable in config file i have to access them in same file or different file in all project.
See below how this can be done.

Configuration.py :
FirefoxPath = "C:/Users/*****/AppData/Local/Mozilla Firefox/firefox.exe"
FirefoxDriver = "C:\\Users\\*****\\Desktop\\python\\geckodriver-v0.24.0-win64\\geckodriver.exe"


__init__.py :
import os
from Configuration import *
binary = FirefoxBinary(FirefoxPath)
driver = selenium.webdriver.Firefox(executable_path=FirefoxDriver, firefox_binary=binary, firefox_profile=profile)

No comments:

Post a Comment

web stats