I have had it. I give up.
Python's documentation sucks beyond belief.
all I want to do is parse a *SIMPLE* config file of name = value pairs
and have python objects named by the name holding the value signified by
value , and I want it to be able to work *WITHOUT* someone having to
download and install additional modules, etc, so I looked up ConfigParser
OK, cool, at least it appears capable. however:
*section of code relevant to issue*
from ConfigParser import SafeConfigParser
cfg = SafeConfigParser("/etc/local-config/myconfig.cfg")
mystuff = cfg.items("Parameters",)#kept giving me an exception that 2
values required
print mystuff
[EMAIL PROTECTED] python_snips]$ ./pymon.py
Traceback (most recent call last):
File "./pymon.py", line 20, in ?
main()
File "./pymon.py", line 15, in main
myname = cfg.items("Parameters",)
File "/usr/lib/python2.3/ConfigParser.py", line 532, in items
d = self._defaults.copy()
OK.. so items doesnt appear to work (the above is my tenth attempt to
get it working) So.. "RTSL!" (Read The Source, Luke) - I grokked
/usr/lib/python2.3/ConfigParser.py" to have a look see at how it does
what it does, and found additional stuff that isnt documented *AT ALL*
.. So..
[EMAIL PROTECTED] python_snips]$ ./pymon.py
Traceback (most recent call last):
File "./pymon.py", line 20, in ?
main()
File "./pymon.py", line 15, in main
myname = cfg.section()
AttributeError: SafeConfigParser instance has no attribute 'section'
OK Obviously I have no clue how the heck this is all supposed to work,
and I have wasted 3 hours of development time on this thing (it aint the
first time I have had issues with Python's Documentation)
Whatever. I give up..
I'll just go write it in Perl. Maybe some day when Python actually has
well structured documentation with *actual working code examples* I
might take another look at trying to learn more of it, but at this
point, time is money, and I can develop the same application in Perl
(probably would have it *done* by now, it's really simple)..
I just needed to vent - I cannot believe how Python ever managed to get
*anywhere* with the state of documentation at python.org
If you want an example of what I would call quality online documentation
- need look no further than php.net (or dev.mysql.com) .. or even
cpan.org (or heck, just run perldoc in commandline.. ) I tried pydoc..
it just doesnt cut the mustard..
OK..
/end rant
Now can someone explan how exactly (preferrably with an actual real
world example) that I can read a configuration file in , say
/etc/local-config/myconfig.cfg into my python script running in
/usr/bin/localscripts , and able to actually use the names as variables
(objects) with the configured values assigned to them?
This drove me nuts the past couple hours, and truthfully, as much as I
like python (I really LIKE python) .. the documentation sucks *SO* bad,
I just cannot justify attempting to learn more and use it for more
projects because of situations like this that do nothing but waste my time.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor