Environment: Windows XP Dell Dimension 4400 128RAM, 40gigHD Python 2.1.1, build 212 (ActiveState) My background - primarily Perl
I created a class to handle base data points that are parsed from a series of "screen scrapings" or screen print images. The pertinent part is: >>>>>>>>>>>>>>> snip <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< class FormLoc: 'base class for Form Locators to hold programming and business logic' count = 0 # *************** constructor *************** # def __init__(self): FormLoc.count = FormLoc.count + 1 self.Row = 0 self.Column = 0 self.Length = 0 self.Contents = "" def setLength(self,len): self.Length = len def setContents(self,con): self.Contents = con if len(con) > self.Length: assert len(con) <= self.Length >>>>>>>>>>>>>>>>> snip <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Now, I used the '__main__' trick and ran this class by itself to test the logic. Some of my test code is: def main(): a = FormLoc() a.setLength( 3 ) a.setContents( "A123" ) x = a.getPattern() When the length is 3 or less, the assert correctly stops the script and, when the length is 4 or greater, correctly lets the script to proceed. Since these items do not exist in a vacuum(is-a has-a relationship), a parsed page will have several of these. Therefore, my other class looks like: import re from FormLoc import FormLoc class FORMbase: 'a template base class for making derived classes' count = 0 def __init__(self): #everyone has an ID and type self.IDNum = FormLoc() self.CustType = FormLoc() That is OK but the problem arises when I try to set the attributes of the various FormLocs that the FORMbase has. Again, use the '__main__' trick to put the class test code in itself: def main(): t = FORMbase() t.IDNum.setLength(2) t.IDNum.setContents( "12345" ) Since the Length of the FormLoc is 2 and the length of the string that is passed to it is 5, I would believe that the assert should stop the script as it did earlier. The other thing that I don't understand is that the various print statements that I put into the FormLoc.setContents() method print when called from the FormLoc class but not from the FORMbase class. Yet, Python will correctly call all of the methods for the FormLoc class. Why doesn't the assert in the FormLoc stop the script when it is called from the FORMbase class? Where is the output from the print statements going? Thanks, Will _______________________________________________ ActivePython mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython