On Fri, Jan 30, 2015 at 4:32 AM, Tim Chase <python.l...@tim.thechases.com> wrote: > I have one that I call int0() > that is my "give me a freakin' int" function which is something like > > def int0(val): > try: > return int(val) > except: > return 0 > > because I deal with a lot of CSV data from client/vendor that has > blanks, "NULL", "---", and plenty of other rubbish to suggest > something that, for my purposes is really just a 0.
What's wrong with "except (TypeError, ValueError):" here? Or even just "except ValueError:", which seems to be what you want? The bare except is still a problem. ChrisA -- https://mail.python.org/mailman/listinfo/python-list