In general, there is a code on the bash, it is necessary to rewrite it on the python.
On the bash, using the source command, variables are loaded, which I use later. How would this be implemented in Python so that you would not have to rewrite already prepared files with variables for bash?
An example of a file from which variables are loaded:

  • Give an example of the contents of the file from which the variables are loaded. - ReinRaus

3 answers 3

ConfigParser may be suitable

    execfile not suitable?

     execfile('path/file.ext') print COMMAND, VERSION 
    • Damn, for sure! Hell, I’ve almost invented such a bike ... :) - Ekkertan

    It seems to me that this bydlokod- tell me how best.

     import shutil shutil.copyfile('path/filename.ext', '') # path/filename.ext это путь к файлу from filename import * print VERSION, COMMAND 
    • Well, you can develop something like this: # - - coding: utf8 - - f = open ('values.txt', 'r') # path / filename.ext is the path to the file f2 = open ('' , 'w') f2.write ( ()) f2.close () f.close () import filename value_list = dir (filename) while value_list: value = value_list.pop () if not value.startswith (' __ '): print value,' = ', filename .__ dict __ [value] - Ekkertan
    • @Ekkertan I asked to simplify, but not to break up :) I do not like the need to copy the file before importing. I would like something like __import __ ('path / filename.ext') But you can only import similar python py and pyd extensions. - ReinRaus