abcd wrote: >> The "Python way" is to validate by performing the operations you need to >> perform and catching any exceptions that result. In the case of your >> example, you seem to be saying that you'd rather raise your own >> exception (which, by the way, should really be a subclass of Exception, >> but we will overlook that) that relying on the interpreter to raise a >> ValueError or a TypeError. Is there really any advantage to this? You >> increase your code size and add *something* to execution time with >> little real purpose. >> >> People coming to Python after C++ or some similar language that allows >> or requires parameter type declarations often don't feel comfortable >> taking this direction to start with, but it works well for most of us. >> >> regards >> Steve > > > So instead of validating input I should just try and use the input as > if it was correct, and let python throw the errors? > Yes. This approach is often referred to as BTAFTP (better to ask forgiveness than permission), as opposed to the LBYL (look before you leap) approach that your original email inquired about.
regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Blog of Note: http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list