[Tutor] Changing the Attribute of a Variable
Marc Tompkins
marc.tompkins at gmail.com
Tue Feb 17 20:17:31 CET 2009
On Tue, Feb 17, 2009 at 11:01 AM, Wayne Watson <sierra_mtnview at sbcglobal.net
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090217/7706fd96/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 20177 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20090217/7706fd96/attachment-0001.jpeg>
More information about the Tutor
mailing list