[Tutor] learning classes (kinda long)

Reed L. O'Brien reed at intersiege.com
Sun Jul 31 06:04:22 CEST 2005


This is a little long
a program consisting of
bsserver.py ## to define server class and methods
bscaller.py     ## to define a test class subclasses for services (imap
http pop dns et al)
bslogger.py ## to log and analyze tests and send emails on
exceptions/failures
bsmain.py  ## that instantiates classes and controls flow
bs.conf  ## the config
given a configuration:

[foo]

fqdn: foo.dom.com
services: http,imap,pop

[bar]

fqdn: bar.dom.org
services: dns,http

then given:

config = ConfigParser.ConfigParser()
config.read('config.txt')

I want to be able to create instances of a class, via a loop; feeding in
the values from the config. something like:

for section in config.sections():
    section = bsserver.Server() 

first I would like for this instance to be named the name of the host in
the section
but i keep getting instances named section I think doing it may require
something more complex than my current understanding. How do I get them
to become individuallly named
Instances?

Additionanlly I would like to call them and pass in their name from teh
section part of the config and also the options fqdn as well as services
as a list.

for section in config.sections():
    section = bsserver.Server(config.get(section, 'fqdn'),
config.get(section, 'services')

currently my server class is defined as:

class Server:
    def fqdn(self, value):
        self.fqdn
    def services(self, value):
        self.services = value
    def name(self, value):
        self.name = value

I have read through learning python and it's info about classes.  While
I feel like I understand it as I read it, I am not doing well
implemeting it.  Any pointers to good reading material is appreciated
and will be read, but discussion of classes would benefit most who are
interested....

TIA,
~r
 






-- 
4.6692916090
'cmVlZG9icmllbkBnbWFpbC5jb20=\n'.decode('base64')
http://www.spreadfirefox.com/?q=affiliates&id=16474&t=1
keyID: 0x0FA09FCE


More information about the Tutor mailing list