[Tutor] I Give Up.
Brian Gustin
brian at daviesinc.com
Sun Jun 18 01:37:40 CEST 2006
Thanks- I had to sit back and with the perl script running nicely, I
took another shot at this to see if I could get it right.. so far so
good, at least no more exceptions being raised..
The perl script runs on a cron, I am thinking I will write this in
python and then wrap it up into a main function, and run it as a daemon,
eliminating the cron..
So, I guess I'll keep trying, now that the project is done, and the
script working, and client happy , and me paid, I have a little free
time to mess around with this..
I am thinking very seriously about building a new set of python
documentation with capability for user contributions and notes, etc, and
putting it online (with searchability to boot) .. maybe a project for
another day..
The one amazing thing I found ridiculously funny:
Python "official" forums- and they actually run phpBB forums? You mean
to tell me no one has written a solid, stable forum software in Python?
OK.. maybe another project to tackle.. I guess I just need to start
building the python documentation the way I think it outta be done...
and see how it goes over..
>>>>help(cfg.items)
>
>
> Help on method items in module ConfigParser:
>
> items(self, section, raw=False, vars=None) method of
> ConfigParser.SafeConfigParser instance
> Return a list of tuples with (name, value) for each option
> in the section.
>
> All % interpolations are expanded in the return values, based on the
> defaults passed into the constructor, unless the optional argument
> `raw' is true. Additional substitutions may be provided using the
> `vars' argument, which must be a dictionary whose contents overrides
> any pre-existing defaults.
>
> The section DEFAULT is special.
>
This is still not 100% clear, and I had to experiement a little bit to
get it to work, but finally got it working.
It does *NOT* say that you must send arguments of the function as
strings, (or as object variables defined elsewhere) , and for the life
of me, I have not been able to get interpolation to work, despite the
examples I have seen.. it is quite unclear.
It would seem all of this python documentation is written assuming that
the reader thinks exactly the same way as the author, and is already
familiar with the function and objects and documentation is written as
if it's just a "reminder of how stuff works"...
Example: I had no idea as to how to do this, and if I had not already
done similar parsing of config files (.ini for example) in other
languages (perl and php both) I would not even have been able to find
this module class on google search , unless I was really lucky ..
It seems sad that the only way I can look up "what kind of function or
module might there be to do x task in Python" has to be found via a
google search.. In the PHP documentation, I can just search out a
"similar" function (say, I want to know how to take two arrays and
combine them, rejecting non-uniques.. I might go to php.net and search
the function list for array() and then I have a list of *all* array
functions that may be used, and able to pick out, for example,
array_merge() .. With python, I dont see any way of doing that, so lots
of really cool stuff that can be done in python is not found..
>
> myname = cfg.sections()
> ^
> Will work for you and provide a list of sections. You will need those
> sections to feed into the items call.
>
Yeah - serves me right for not paying attention to spelling.. :)
>
>
> No don't!
>
> You are almost there.
>
Close.. we'll see how it goes from here, now that Im not under pressure
to get this script done :)
> I came to Python after Perl and lot's of other languages. I think
> Python is better, but it helps to have someone to talk to when things
> are going badly.
>
Very true.. and sometimes talking about teh issue the solution suddenly
becomes evident :)
>
> I liked the old layout better, but presumably you found this:
> http://docs.python.org/lib/RawConfigParser-objects.html
>
Actually, no I didnt find that.. another area where Documentation sucks-
It's so very easy to miss some important thing in the way this stuff
is categorized and structured..
In fact, I actually searched for python.org Documentation
ConfigParser.read and still didnt see anything come up for python.org
documentation....
Oh well. I'll see if I can get this thing to work like the perl script I
just wrote...
More information about the Tutor
mailing list