Re: [Tutor] Changing the Attribute of a Variable
>> Initally, a variable. self.stop_time is created as type datetime.time, >> with the default value 06:00:00, a time stamp, during entry into the >> mainloop. self.stop_time = datetime.time(10,10,10). The user reads his >> configuration file with the time stamp value of 08:00:00. self.time_stop >> becomes type string. He then goes to a dialog to change time stop, and it >> tries to access self.time_stop, and find is needs to have the attribute >> strftime, as in: >> set_loc_dict[ "stop_time" ] = self.stop_time.strftime("%H:%M:%S") >> When reading the configuration file, how do I make sure that >> self.time_stop is really has the strftime attribute? > > You already received an answer to your immediate question, but I wanted to > clarify: "strftime" is NOT an attribute, it's a method. Calling the > strftime method of a time object returns a string, formatted according to > the pattern you specify - so what you're storing as "stop_time" is not a > time, but a string. this is a reply to both: wayne: the initial setting of self.stop_time as a datetime.time object seems to be ok, but i'm uncomfortable with the fact that after "[the] user reads his [config] file," it becomes a str. i think that the code that processes the config file should be setting self.stop_time as another datetime.time object, so that way, when you want to set the value for set_loc_dict, it would not have any problems calling its strftime() method. marc: i will slightly disagree with you with regards to strftime *not* being an attribute. it *is* an attribute, just not a *data attribute*... i call it a "function attribute," but that's just terminology. any time you have an object x with an attribute y, the fact that you can issue x.y means that y is indeed an attribute of x. if it's a data attribute, you access it with x.y. if it's a function attribute, i.e., a method, you also access it with x.y, esp. if you want to pass the function object around, and finally, if you actually want to *execute* it *and* it's a method, then you add the parens, x.y(). hope this helps, -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Python Web Development with Django", Addison Wesley, (c) 2009 http://withdjango.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Add readline capabilities to a Python build 2.6 on Ubuntu
Le Mon, 16 Feb 2009 22:34:23 -0700, Eric Dorsey a écrit : > Greetings Tutor: > I've managed to install Python 2.6 on my Ubuntu VM from source, however, it > looks as though I missed something important along the way. My 2.6 > interpreter does not have readline support (example: I cant hit up arrow to > repeat the last command) Is there a way to add this functionality now? > > Or alternative, if I just rebuild it, does anyone know the flag or verbage > to get readline support in? As far as I know, it's built-in by default. But I have 2.5.2, not 2.6. Have you tried to import it, just to check? s...@o:~/prog/io$ python Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import readline >>> readline denis -- la vida e estranya ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] exec "self.abc=22" ?
On Mon, Feb 16, 2009 at 10:01 PM, Wayne Watson wrote: > My limited repertoire. Actually, there wasn't much of a traceback. It came > up in a small OK dialog. I copied what I could. I see my image I used above > did make it to the list, so here's the skinny. > > > I see Marc covered it with setattr. How does one do it with a dictionary? > What else lurks out there that might be useful along these lines? It all depends on what you will use it for. As said, exec should work, but it usually is not the way to go - if there's outside input involved, it's _extremely_ unsafe, if everything comes from inside your program it's an ugly sledgehammer to crack a nut. So please take one step back - WHY do you want to do this? Where does this string "self.abc = 22" come from? What are the values it can have? Can you create a toy example that shows the problem you want to solve? -- André Engels, andreeng...@gmail.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Changing the Attribute of a Variable
On Tue, Feb 17, 2009 at 12:16 AM, wesley chun wrote: > marc: i will slightly disagree with you with regards to strftime *not* > being an attribute. it *is* an attribute, just not a *data > attribute*... i call it a "function attribute," but that's just > terminology. any time you have an object x with an attribute y, the > fact that you can issue x.y means that y is indeed an attribute of x. > if it's a data attribute, you access it with x.y. if it's a function > attribute, i.e., a method, you also access it with x.y, esp. if you > want to pass the function object around, and finally, if you actually > want to *execute* it *and* it's a method, then you add the parens, > x.y(). > Which follows from the fact that in Python, functions are objects too. However, in the context of the OP's question, I think that if he referenced strftime with no parentheses the result would NOT be what he expected or intended; the distinction between methods and what you call "data attributes" can be an important one. Point taken, though. -- www.fsrtechnologies.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] urllib unquote
On Tue, Feb 17, 2009 at 08:54, Norman Khine wrote: > Thank you, but is it possible to get the original string from this? You mean something like this? >>> urllib.quote('hL/FGNS40fjoTnp2zIqq73reK60=\n') 'hL/FGNS40fjoTnp2zIqq73reK60%3D%0A' Greets Sander ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] urllib unquote
On Tue, Feb 17, 2009 at 1:24 PM, Norman Khine wrote: > Thank you, but is it possible to get the original string from this? What do you mean by the original string Norman? Look at these definitions: Quoted String: In the different parts of the URL, there are set of characters, for e.g. space character in path, that must be quoted, which means converted to a different form so that url is understood by the program. So ' ' is quoted to %20. Unquoted String: When %20 comes in the URL, humans need it unquoted so that we can understand it. What do you mean by original string? Why are you doing base64 encoding? And what are you trying to achieve? Perhaps these can help us to help you better? -- -- Senthil ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Add readline capabilities to a Python build 2.6 on Ubuntu
On Mon, 16 Feb 2009 22:34:23 -0700 Eric Dorsey wrote: > Greetings Tutor: > I've managed to install Python 2.6 on my Ubuntu VM from source, > however, it looks as though I missed something important along the > way. My 2.6 interpreter does not have readline support (example: I > cant hit up arrow to repeat the last command) Is there a way to add > this functionality now? > > Or alternative, if I just rebuild it, does anyone know the flag or > verbage to get readline support in? I think you need to recompile it again, this time make sure that "libreadline5-dev" package is installed. Hope that help. Ziyad. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Add readline capabilities to a Python build 2.6 on Ubuntu
Bonjour, Je suis absente jusqu'au 22/02/09 inclus. Cordialement. Geneviève ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] exec "self.abc=22" ?
On Mon, Feb 16, 2009 at 4:01 PM, Wayne Watson wrote: > I see Marc covered it with setattr. How does one do it with a dictionary? Instead of trying to create variables with variable names, use the names as keys in a dict. So instead of exec "self.abc=22" you might use self.values = {} self.values['abc'] = 22 Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] urllib unquote
On Mon, Feb 16, 2009 at 8:12 AM, Norman Khine wrote: > Hello, > Can someone point me in the right direction. I would like to return the > string for the following: > > Type "help", "copyright", "credits" or "license" for more information. import base64, urllib data = 'hL/FGNS40fjoTnp2zIqq73reK60%3D%0A' data = urllib.unquote(data) print base64.decodestring(data) > ???Ը???Nzv̊??z?+? > > What am I missing? How is data created? Since it doesn't decode as you expect, either it isn't base64 or there is some other processing needed. Do you have an example of a data string where you know the desired decoded value? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Changing the Attribute of a Variable
Note that the diagnostic output in the image shows attributeError: 'str' object has no attribute 'strftime'. Let me see if I clarify what's really going on by including some of the code. In Sentinel_GUI, the mainloop, the code shows (hard coded default values): ... self.slowdown = 1 self.stop_time = datetime.time(6,0,0) <<--- self.start_time = datetime.time(18,0,0) The code for OpenConfigFile is below, which reads the text file containing the configuration variables and values. ===Sample of config file== Sentinel NC Configuration File Sentinel User 3 - 1/3/2009 (Meteor Software) config_file_name=Initial.sen mask_file_name=*none* gray_scale=True post_event_stack=False post_event_format=Tiff 2 show_real_time=False hourly_rate=12 slowdown=1 start_time=22:00:00 stop_time=06:00:00 lat=40.0 ... ===end of sample== Note below that I'm trying to pick off "user" variables in the file that are dates. self.config_var_list contains DAT (user) type for stop_time. Note the use of setattr at the bottom. I may have gone wrong here, when the code handles the DAT differently than the other user variables. See the code after this, where the error is raised when the dialog begins to be activated. There are a few more comments below this. ==OpenConfigFile== def OpenConfigFile(self): def time_tuple(tstring): t = tstring.split(':') print 'here is t', t tnum = () for j in range(0,len(t)): tnum = tnum+(string.atoi(t[j]),) return tnum print "OCFile entered" print config_file_name = askopenfilename( title="Open Configuration File", filetypes=CEN_FILE_TYPES ) config_file=open(config_file_name,'r') first_line = config_file.readline() # skip first line for (j,newline) in enumerate(config_file): aline = newline[:-1] aline.rstrip() (config_var, config_value) = aline.split('=') config_type = self.config_var_list[j][1][1] self_var = "self." + config_var print "ocf: ",config_var,config_value,"self_var=",self_var if config_var == DAT: # Date type, expecting hh:mm:ss t_ntup = time_tuple(config_value) stime = datetime.time(t_ntup[0],t_ntup[1],t_ntup[2]) print "type stime: ",type(stime) # Date vars should be type datetime.time config_value = str(stime) else: self_var_assignment = self_var +'='+ config_value print "self_var_assignment", self_var_assignment abc = self # self_var_assignment setattr(self, config_var, config_value) config_file.close() =End of OpenConfigFile=== When the program brings up the dialog, this piece of code gets me into trouble, as marked. ===OperationalSettings=== def OperationalSettings(self): print "OSett self = ", self, "type =", type(self) print set_loc_dict = {} set_loc_dict[ "ok" ] = False set_loc_dict[ "color" ] = 2 if self.gray_scale: set_loc_dict[ "color"] = 1 print "gray scale now--wtw: ", self.gray_scale set_loc_dict[ "hourly_rate" ] = self.hourly_rate print "wtw self.stop_time", self.stop_time, type(self.stop_time) # set in GUI as datetime.time(6,0,0) # HEY wtw self.stop_time.strftime("%H:%M:%S") set_loc_dict[ "stop_time" ] = self.stop_time.strftime("%H:%M:%S") <
Re: [Tutor] urllib unquote
it is my error, the data is a sha string and it is not possible to get the string back, unless you use rainbowtables or something of the sort. Kent Johnson wrote: On Mon, Feb 16, 2009 at 8:12 AM, Norman Khine wrote: Hello, Can someone point me in the right direction. I would like to return the string for the following: Type "help", "copyright", "credits" or "license" for more information. import base64, urllib data = 'hL/FGNS40fjoTnp2zIqq73reK60%3D%0A' data = urllib.unquote(data) print base64.decodestring(data) ???Ը???Nzv̊??z?+? What am I missing? How is data created? Since it doesn't decode as you expect, either it isn't base64 or there is some other processing needed. Do you have an example of a data string where you know the desired decoded value? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Possible to change values of scalar function parameters?
Is there a way to change values of scalar function parameters? I know you can change the values of parameters if the parameter is a mutable type like a list, but is there a way to update the value of scalar parameters of type integer or string? Simple example: Is there a way to have the following function update its changeme parameter in a 'call by reference' manner? >>> def test1( changeme ): changeme = 'Changed!' >>> ref_value = 'blah' >>> test1( ref_value ) >>> ref_value 'blah' Thanks! Malcolm ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Possible to change values of scalar function parameters?
On Tue, Feb 17, 2009 at 11:57 AM, wrote: > Is there a way to change values of scalar function parameters? I know you > can change the values of parameters if the parameter is a mutable type like > a list, but is there a way to update the value of scalar parameters of type > integer or string? > > Simple example: Is there a way to have the following function update its > changeme parameter in a 'call by reference' manner? > def test1( changeme ): > changeme = 'Changed!' No, not a simple way at least. Possibly you can do it with hackery involving stack frames but I wouldn't recommend that. Either pass the values in some kind of container (list, dict, class instance) or return the new value and assign it in the caller. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Possible to change values of scalar function parameters?
Kent, > No, not a simple way at least. Possibly you can do it with hackery involving stack frames but I wouldn't recommend that. Either pass the values in some kind of container (list, dict, class instance) or return the new value and assign it in the caller. That's what I thought. Thank you! Malcolm ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Changing the Attribute of a Variable
On Tue, Feb 17, 2009 at 4:44 AM, Wayne Watson wrote: > Note that the diagnostic output in the image shows attributeError: 'str' > object has no attribute 'strftime'. > > Let me see if I clarify what's really going on by including some of the > code. > Everything in Python - both variables and code - is an object. Objects have attributes - data, basically - and methods - functions - associated with them. (As Wesley pointed out, since pieces of code are also objects, methods are attributes too.) However, not all objects have the same attributes or methods associated with them! datetime.time objects have a "strftime" method, which, when called, returns a string representation of the time. String objects do not have any such method or data attribute, hence the error. You're showing us both too much code and too little - print "wtw self.stop_time", self.stop_time, type(self.stop_time) # set in GUI as datetime.time(6,0,0) # HEY wtw self.stop_time.strftime("%H:%M:%S") set_loc_dict[ "stop_time" ] = self.stop_time.strftime("%H:%M:%S") <from validate import Validator ... > cfgFileName = os.getcwd() + os.sep + 'fsr_1500.ini' > tmpStr = """ > npiXMLFile = string(default="npiMap.XML") > UCFformLength = integer(min=50, max=80, default=66) > FIformLength = integer(min=50, max=80, default=64) > OutformLength = integer(min=50, max=80, default=64) > IncludeLegacy = boolean(default=False) > TopLeft = int_list(min=2, max=2) > BottomRight = int_list(min=2, max=2) > FIHist = string_list(default=None) > UCFHist = string_list(default=None) > OutHist = string_list(default=None) > LastRunUCF = boolean(default=True) > LastRunPrinter = boolean(default=False) > detailLeft = integer(min=0, max=80, default=0) > detailTo = integer(min=0, max=80, default=9) > detailPOS = integer(min=0, max=80, default=19) > detailCode = integer(min=0, max=80, default=25) > detailMods = integer(min=0, max=80, default=32) > detailDiags = integer(min=0, max=80, default=44) > detailCharge = integer(min=0, max=80, default=49) > detailUnits = integer(min=0, max=80, default=58) > detailEPSDT = integer(min=0, max=80, default=62) > detailEMG = integer(min=0, max=80, default=22) > detailID = integer(min=0, max=80, default=67) > bodyLeftBlock = integer(min=0, max=80, default=0) > bodyMidBlock = integer(min=0, max=80, default=24) > bodyRightBlock = integer(min=0, max=80, default=49) > bodyLabelEdge = integer(min=0, max=80, default=40) > ConfirmSuccess = boolean(default=True) > """ > cfgSpec = StringIO.StringIO(tmpStr) > cfgFile = ConfigObj(cfgFileName, > configspec=cfgSpec, raise_errors=True, > write_empty_values=True, > create_empty=True, indent_type='', list_values=True) > vtor = Validator() ... > cfgFile['TopLeft'] = data.GetMarginTopLeft() # writing a couple of > values > cfgFile['BottomRight'] = data.GetMarginBottomRight() > ... > test = cfgFile.validate(Global.vtor, copy=True) > cfgFile.write() > Looking at that, I see a few things I want to clean up. That's the danger (and advantage) of exposing your own code to public scrutiny... -- www.fsrtechnologies.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Changing the Attribute of a Variable
> # Date vars should be type datetime.time > config_value = str(stime) this is pretty much the offending code right here... in fact, the comment contradicts the assignment. it says that date vars should be of type datetime.time, yet it assigns a *string* to config_value, which then gets set later using setattr(). if you just remove that assignment, things should work better..., at least from what i can see. good luck! -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 "Python Fundamentals", Prentice Hall, (c)2009 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Possible to change values of scalar function parameters?
wrote No, not a simple way at least. Possibly you can do it with hackery involving stack frames but I wouldn't recommend that. Either pass the values in some kind of container (list, dict, class instance) or return the new value and assign it in the caller. That's what I thought. Thank you! But don't forget that in python you can return multiple values from a function... def f(): return 42, 66, 101 a,b,c = f() HTH, -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Possible to change values of scalar function parameters?
Alan, > But don't forget that in python you can return multiple values from a > function. Yes. Thank you! Malcolm ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Changing the Attribute of a Variable
Title: Signature.html Yes, about public scrutiny of code and your paragraphs on "Everything.." and "However, not all..."-- both understood. Here's the print from the code line below. Second line from the top. Regarding, ConfigObj, I was aware of it when I decided to go this route. That's the one that uses has an init file like Windows? Rather than have to go through a learning process on it (the Win init module/object), and some uncertainty about it's acceptability in my situation, I thought I'd be more exploratory and proceed as I have. So far it has paid off in many learning dividends. ConfigObj, if not the Win stuff, may be attractive. Anyway, I'd like to proceed for the moment with this effort. Marc Tompkins wrote: On Tue, Feb 17, 2009 at 4:44 AM, Wayne Watsonwrote: Note that the diagnostic output in the image shows attributeError: 'str' object has no attribute 'strftime'. Let me see if I clarify what's really going on by including some of the code. Everything in Python - both variables and code - is an object. Objects have attributes - data, basically - and methods - functions - associated with them. (As Wesley pointed out, since pieces of code are also objects, methods are attributes too.) However, not all objects have the same attributes or methods associated with them! datetime.time objects have a "strftime" method, which, when called, returns a string representation of the time. String objects do not have any such method or data attribute, hence the error. You're showing us both too much code and too little - print "wtw self.stop_time", self.stop_time, type(self.stop_time) # set in GUI as datetime.time(6,0,0) # HEY wtw self.stop_time.strftime("%H:%M:%S") set_loc_dict[ "stop_time" ] = self.stop_time.strftime("%H:%M:%S") <
Re: [Tutor] Changing the Attribute of a Variable
On Tue, Feb 17, 2009 at 7:44 AM, Wayne Watson wrote: > ==OpenConfigFile== > def OpenConfigFile(self): > def time_tuple(tstring): > t = tstring.split(':') > print 'here is t', t > tnum = () > for j in range(0,len(t)): > tnum = tnum+(string.atoi(t[j]),) return tnum > > print "OCFile entered" > print > config_file_name = askopenfilename( title="Open Configuration File", > filetypes=CEN_FILE_TYPES ) > config_file=open(config_file_name,'r') > first_line = config_file.readline() # skip first line > for (j,newline) in enumerate(config_file): > aline = newline[:-1] > aline.rstrip() > (config_var, config_value) = aline.split('=') > config_type = self.config_var_list[j][1][1] > self_var = "self." + config_var > print "ocf: ",config_var,config_value,"self_var=",self_var > if config_var == DAT: # Date type, expecting hh:mm:ss What is DAT? Where is it defined? Why should the config variable name (config_var) be equal to DAT? Is this code block being executed at all? Kent > t_ntup = time_tuple(config_value) > stime = datetime.time(t_ntup[0],t_ntup[1],t_ntup[2]) > print "type stime: ",type(stime) > # Date vars should be type datetime.time > config_value = str(stime) > else: > self_var_assignment = self_var +'='+ config_value > print "self_var_assignment", self_var_assignment > abc = self > # self_var_assignment > setattr(self, config_var, config_value) > config_file.close() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Changing the Attribute of a Variable
On Tue, Feb 17, 2009 at 11:01 AM, Wayne Watson wrote: > Here's the print from the code line below. > > Second line from the top. > There it is - stop_time is a str at this point in the program, so has no strftime attribute or method. Step back through your code and see why... I find Control-F very helpful in situations like this! > > Regarding, ConfigObj, I was aware of it when I decided to go this route. > That's the one that uses has an init file like Windows? Rather than have to > go through a learning process on it (the Win init module/object), and some > uncertainty about it's acceptability in my situation, I thought I'd be more > exploratory and proceed as I have. So far it has paid off in many learning > dividends. ConfigObj, if not the Win stuff, may be attractive. Anyway, I'd > like to proceed for the moment with this effort. > There's nothing sacred about the ".ini" extension - any text file that contains "variable = value" pairs is game. ConfigObj is not Windows-centric. The advantage - which is what I was trying to show when I posted that gosh-awful hunk of code - is that you can define the format of the file in one central section of your program - it could even be a separate module if you wanted - and in one swell foop you tell ConfigObj the name of the variable, its type, acceptable values or range, and a default value in case it's missing. Opening, reading, closing, writing, validating - all handled. I certainly wouldn't want to dissuade you from writing your own as a learning exercise - I'm glad I did - but each time I need to update one of my old programs that still uses my homegrown ConfigFile, that's the first thing I re-factor. -- www.fsrtechnologies.com <>___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Add readline capabilities to a Python build 2.6 on Ubuntu
On Mon, 16 Feb 2009 22:34:23 -0700, Eric Dorsey wrote: > Greetings Tutor: > I've managed to install Python 2.6 on my Ubuntu VM from source, however, > it looks as though I missed something important along the way. My 2.6 > interpreter does not have readline support (example: I cant hit up arrow > to repeat the last command) Is there a way to add this functionality > now? WORKSFORME I have Ubuntu and python2.6 and the up arrow history works fine. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Changing the Attribute of a Variable
Yes, on F3 (ctrl-F). I use it a lot. After the dust clears on how to correct this implementation, I'll give ConfigObj more consideration. (I think a subsequent post I made with two images in it showing the layout of the program in action got side tracked here. I got a msg from the list, saying the moderator had to approve something--probably it. Whatever I said in it might be somewhat irrelevant here. So I continue. See whoops at end!) Ok, let's see how this works. I've defined this function and the config_var_list. stop time is the last entry shown. It is part of the constructor for mainloop, Sentinel_GUI. and loads sdict as shown. def Set_ConfigDictionary(): config_var_list = (['config_file_name', ['Initial.sen', STR]], ['mask_file_name', ['xyz', STR]], ... ['stop_time', ['datetime.time(6, 0, 0)', DAT]], ... ) # load sdict sdict = {} for j in range(0, len(config_var_list)): # print "j: ", j, "str part: ", str(config_var_list[j][0]), config_var_list[j][1] sdict[str(config_var_list[j][0])] = config_var_list[j][1][0] ... self.sdict = sdict self.config_var_list = config_var_list ... sdict and config_var_list become global to Sentinel_GUI. The first index of conf_var_list maintains order for sdict. That is, when I want to output the config file, I use to to fetch from sdict what I need, which is a value and the "user" type, i.e., STR, DAT, BOO, etc. Now in SaveConfigFile, I go merrily along thusly: ... # SAVE CONFIG FILE items = self.sdict.keys() items.sort() for (j, conf_entry) in enumerate(self.config_var_list): varName = conf_entry[0] varType = self.config_var_list[j][1][1] # Note, date-time vars are in hh:mm:ss varValue = eval('self.' + varName) var_assignment = varName + "=" + str(varValue) <<--- Beep, beep config_file.write(var_assignment + "\n") ... "Beep, beep" shows the likely problem. I had coded this loop earlier to try (and not succeeding) to take into consideration DAT, BOO, ..., etc, but put aside how to handle the var_assignment statement (Note, Strictly speaking I should be using TIM and not DAT, for clarity.). Here, I suspect that I should put out something like datetime.time(11, 20, 10). The time being 11:00:10. Instead I chose, to put 11:00:10 in the file. I'm still a bit confused about what the file entry should be here. However! I think I may have drifted into the realm of : :-) UCFformLength = integer(min=50, max=80, default=66) FIformLength = integer(min=50, max=80, default=64) Maybe things are looking up for ConfigObj!!! Whoops footnote: I think I got you and Kent confused, but I think I'm on track here with thinking of the right person. I posted the two pix to him. Marc Tompkins wrote: On Tue, Feb 17, 2009 at 11:01 AM, Wayne Watsonwrote: Here's the print from the code line below. Second line from the top. There it is - stop_time is a str at this point in the program, so has no strftime attribute or method. Step back through your code and see why... I find Control-F very helpful in situations like this! Regarding, ConfigObj, I was aware of it when I decided to go this route. That's the one that uses has an init file like Windows? Rather than have to go through a learning process on it (the Win init module/object), and some uncertainty about it's acceptability in my situation, I thought I'd be more exploratory and proceed as I have. So far it has paid off in many learning dividends. ConfigObj, if not the Win stuff, may be attractive. Anyway, I'd like to proceed for the moment with this effort. There's nothing sacred about the ".ini" extension - any text file that contains "variable = value" pairs is game. ConfigObj is not Windows-centric. The advantage - which is what I was trying to show when I posted that gosh-awful hunk of code - is that you can define the format of the file in one central section of your program - it could even be a separate module if you wanted - and in one swell foop you tell ConfigObj the name of the variable, its type, acceptable values or range, and a default value in case it's missing. Opening, reading, closing, writing, validating - all handled. I certainly wouldn't want to dissuade you from writing your own as a learning exercise - I'm glad I did - but each time I need to update one of my old programs that still uses my homegrown ConfigFile, that's the first thing I re-factor. -- www.fsrtechnologies.com ___ Tut