modifiable config files in compiled code?

Larry Bates lbates at syscononline.com
Thu Mar 10 10:46:15 EST 2005


Note: my comments assume Windows distribution.

Why do you think you can't you have a config file after you convert
your program to an executable?  I do it all the time and so do many
other programs.  The .INI config file is just a separate file that
provides a good way to pass client supplied information into an
executable (I'm assuming when you say executable you mean something
that goes through a program like py2exe).  You can also pass in
information as arguments to your program or as I normally do some
combination of the two.

Steps I take:

1) Run program through py2exe
2) Build an Inno Installer script to gather all my program parts
and my .INI and README.TEXT, etc. files together into a single
setup.exe.  This may include things like data files or other
"extra" files that the program requires.
3) Insert Inno Installer commands to make any install-time
changes that are required to registry or my .INI file.
4) Have Inno Installer compile everything together into setup.exe


viola' you have a single file that can be installed on any computer
that will run without Python installation.

-Larry Bates


gaudetteje at gmail.com wrote:
> Hi All,
> 
> I've been trying to come up with an elegant solution to this problem,
> but can't seem to think of anything better than my solution below.
> 
> I have a Python program that needs to be converted into an executable.
> The problem is that I have a "config" template file that I've been
> using to modify initialization constants such as paths, global
> variables, structures, etc.  Obviously, once I convert my code into an
> executable I can no longer read/write to my configuration file.
> 
> My solution was to convert this config file into a standard ASCII text
> document and have Python parse it for user set variables.  This doesn't
> seem like the most elegant of solutions; however, and I thought others
> must have implemented a better way than this.
> 
> Anyone have a better solution for this problem?
> 
> Jay
> 



More information about the Python-list mailing list