On 18/12/2007, Jim Morcombe <[EMAIL PROTECTED]> wrote: > Now, if I take int(string) the code will work, except it crashes out when > the data is null. > > student.row = int(student.row) > ValueError: invalid literal for int() with base 10: '' > > What is the easiest and recomended way of turning the strings into numerics?
It doesn't crash -- it just throws an exception. Exceptions are a big part of python; you should learn to love them :-) As an example, you could do this: try: student.row = int(student.row) except ValueError: student.row = None (assuming that setting student.row to None is the appropriate thing to do when it's blank) -- John. _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
