[Tutor] How to control list input ?
alan.gauld at blueyonder.co.uk
Thu Jun 3 18:02:13 EDT 2004
> class Template:
> def __init__(self,doctdbname):
> def addDoctor(self, doctname, doctlist):
> def printDoctor(self, 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;
> 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
> way of checking the input to make sure it corresponds ?
I'd solve both issues by using dictionaries insteadof lists. Then
of trying to figure out the two index values, just pass in the names
of the attributes you want - which your code doesn't give any clues
about! - and use them as keys.
More information about the Tutor