Difference between revisions of "Russ Python Tips and Techniques"

From OpenCircuits
Jump to navigation Jump to search
(Created page with "= What = Just starting Feb 2017 check history to see if progress is being made = Parameters for Applications = = Logging = = Restart = = Threading with Tkinker =")
 
Line 3: Line 3:
  
 
= Parameters for Applications =
 
= Parameters for Applications =
 +
 +
 +
There are various ways of storing start up parameters for applications.  In the old days almost all windows programs had a "ini" file.  Linux had/has "config" files.  In both cases these are text files that are easily edited with a simple text editor.  More recently xml files ( which i tend to hate ) have come into vogue.  Finally some applications give you a gui for editing configuration values and then save them any way they want, perhaps in the "registry".
 +
 +
Using a gui is the easiest way for the user in particular the naive user.  They are also a lot of work to implement and maintain.  So I favor a flat, non-xml file.  But what file?  For Python my answere is a python.py file that has pretty much one class, Parameters, that is implemented as a singleton ( in what ever way you want to implement singletons ).  These are easy to implement, easy to maintain, and very flexible.  They can also do clever things like detecting what operating system they are running on and make automatic adjustments.  There are no issues of converting type into strings for the file.  Comments are easily included. Loading can print the progress of initialization.
 +
 +
I will put a brief sample here soon so you can see what a file looks like.
 +
 +
<pre>
 +
code comming here
 +
</pre>
  
 
= Logging =
 
= Logging =

Revision as of 09:22, 1 February 2017

What

Just starting Feb 2017 check history to see if progress is being made

Parameters for Applications

There are various ways of storing start up parameters for applications. In the old days almost all windows programs had a "ini" file. Linux had/has "config" files. In both cases these are text files that are easily edited with a simple text editor. More recently xml files ( which i tend to hate ) have come into vogue. Finally some applications give you a gui for editing configuration values and then save them any way they want, perhaps in the "registry".

Using a gui is the easiest way for the user in particular the naive user. They are also a lot of work to implement and maintain. So I favor a flat, non-xml file. But what file? For Python my answere is a python.py file that has pretty much one class, Parameters, that is implemented as a singleton ( in what ever way you want to implement singletons ). These are easy to implement, easy to maintain, and very flexible. They can also do clever things like detecting what operating system they are running on and make automatic adjustments. There are no issues of converting type into strings for the file. Comments are easily included. Loading can print the progress of initialization.

I will put a brief sample here soon so you can see what a file looks like.

code comming here

Logging

Restart

Threading with Tkinker