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 Watson <sierra_mtnv...@sbcglobal.net> 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")   <<----problem, see image in first post

I'd like to see the output of that "print" - I'm pretty sure that "type" will return "str", not "time". 

On another front, have you considered ConfigObj (http://www.voidspace.org.uk/python/modules.shtml#configobj)?  When I first came to Python, I wrote myself a config-file handler (serializing to XML, actually) and it worked OK - but everything was so much work!  I discovered ConfigObj and life is good.  Here's a quick example from one of my early programs I refactored to use ConfigObj (NOT as a shining example of code, but just to show the power):

from configobj import ConfigObj
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

--


           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
            

                "Nature, to be commanded, must be obeyed."
                                   -- Sir Francis Bacon 

                    Web Page: <www.speckledwithstars.net/>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to