Error checking in Python

BGM no.spam at comcast.net
Mon Jun 9 15:59:45 CEST 2003


Hello all:

I am new to python, coming from a modest C background. Recently, I was
writing some custom module in Python and I was wondering about one thing:
Since the user of the module can pass any argument they wish, then it
seemed like a good idea to check ,say, for type errors within the
functions in the module. However, it occurred to me that if some of these
functions are used in in the inner loops of some program, there could be a significant
slow-down. When writing their own modules, what do the users of the list
usually do? Do you leave the responsibility for type checking to the user
of the functions, or do you implement this in the modules, or some
combination of these two approaches?

I apologize if there is a simple mechanism that Python provides that I
have perhaps not learned about. (Other than throwing an exception during
runtime)

-------------------
BGM.





More information about the Python-list mailing list