How to save initial configuration? (program installation)

Steve Holden steve at holdenweb.com
Mon Jun 25 17:34:34 CEST 2007


kyosohma at gmail.com wrote:
> On Jun 25, 10:02 am, Jason Zapman II <zapman... at gmail.com> wrote:
>> I've written a program.  To install this program, I'm going to need to
>> initialize some stuff for the users environment, specifically the name/
>> location of an internal state file.
>>
>> Currently, I'm hard coding the location of this file, but that's in-
>> elegant.  What I'd like to do is just ask the user, with a suggested
>> default.
>>
>> My question is how do I save this answer?  It's kind of a chicken-and-
>> egg problem.
>>
>> The only solution I've thought of is to write something that's self
>> modifying, but that's ugly (go in, grep for this variable
>> initialization, re-write that line with the new value, quit).  Is
>> there a better way to do this?  There almost has to be...
>>
>> If not, are there some 'best practices' on how to do the self-
>> modification?
>>
>> Thanks for any help;
>> Jason
> 
> I would think you could pop-up some dialog when the program is first
> run to ask where they want the file to be. On the first run though,
> you can just have the config file located in the current working
> directory with the script file itself. Then just move it or save a new
> copy to the new location and delete the original.
> 
> Mike
> 
Or, better still, leave it in place to act as the defaults for the next 
user who wants to start using this package?

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------




More information about the Python-list mailing list