Note that there are some explanatory texts on larger screens.

plurals
  1. POPass command line variables between Python files. Totally stuck
    primarykey
    data
    text
    <p>I have what seems like a very easy problem with an easy solution just beyond my reach.</p> <p>My setup:</p> <p>A) Driver file (runs the test script) B) Connection file (using Requests) C) Parameters file</p> <p>The paramenters file has 6 variables with things like server IP, login, pass etc.</p> <p>The Driver file has a praser which reads the properties file and fills in the blanks.</p> <blockquote> <p>driver.py paramtersfile.csv</p> </blockquote> <p>This works fine. However, I added a PORT variable to the parameters file which needs to be seen by B) Connection file. This connections file is never called explicitly, rather just imported into the driver file for its connection and cookie methods.</p> <p>How do I carry over the parsed variables (from sys.argv) from paramtersfile.csv to the Connections file (or any other file which is used to run my script?</p> <p>Thank you stackoverflow community</p> <p>Edit:</p> <p>I got it to work using the obvious way of passing on the arguments into the class (self.foo) of whatever module/file I needed.</p> <p>My question from before was along the lines of this idea:</p> <p>You do something like</p> <p>loadproperties(propertiesfile)</p> <p>then from any other python script you could just do </p> <p>import propertyloader </p> <p>which would load a list of immutable properties into the current space</p> <p>Seems very convenient to just do </p> <p>url = propertyloader.url</p> <p>instead of</p> <p>class Connect (host, port, pass, <strong>url</strong>):</p> <p>self.<strong>url</strong> = <strong>url</strong></p> <p>loader = requests(secure, <strong>url</strong>)</p> <p>blah blah blah...</p> <p>Seems like a headache free way of sharing common parameters between different parts of the script.</p> <p>Maybe there's still a way of doing this (extra credit question)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload