[Tutor] How to control list input ?

Michele Alzetta michele.alzetta at aliceposta.it
Thu Jun 3 12:39:13 EDT 2004


For a program I'm fooling about with I created the following class
(still largely incomplete):

class Template:
    
    def __init__(self,doctdbname):
        self.doctor = shelve.open(doctdbname, writeback = True)
        
    def addDoctor(self, doctname, doctlist):
        self.doctor[doctname] = doctlist
    
    def printDoctor(self, doctname):
        self.doctor[doctname]
        
    def alterDoctor(self, doctname, index1, index2, newvalue):
        self.doctor[doctname][index1][index2] = newvalue

For my purposes doctlist can't be just any arbitrary list of lists; it
will have to be made of a precise number of elements, that musn't be
hardcoded but definable; how do you suggest I try coding a) a way in
which to define what the structure of my list ought to be like and b) a
way of checking the input to make sure it corresponds ? 

-- 
Michele



More information about the Tutor mailing list