"Theerasak Photha" <[EMAIL PROTECTED]> writes: > I wrote this for someone else to take an object and list of types, > then check if obj is one of those types, raising an error otherwise.
This is a way of programming known as "Look Before You Leap" (LBYL). It is most likely a mistake to do this in Python. (That's not an absolute, but it's the smart way to bet.) Far better is to take the objects passed, *use* them in the way that you need to use them, and catch exceptions that get raised at the point where there is enough context to handle them. This is the "Easier to Ask Forgiveness than Permission" (EAFP) principle, and it is considered to be far more Pythonic. <URL:http://jaynes.colorado.edu/PythonIdioms.html> -- \ "Prediction is very difficult, especially of the future." -- | `\ Niels Bohr | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list