[EMAIL PROTECTED] wrote: > Hi all, > > I'm new to Python and I'm just wordering if my approch is correct. > Here's an example. I'm making sure that the length and types are > correct.
Don't worry much about the type of parameters, it turns out passing wrong data into a constructor is a problem that is both easy to avoid and catch once it happens. Here is also an alternative to your code try: assert len(data) in (1, size), 'incorrect size' assert len(data)==len( [ x for x in data if type(x)==int ] ), 'noninteger data in the list' except Exception, exc: raise FormatError('Data error: %s' % exc) i. -- http://mail.python.org/mailman/listinfo/python-list