Billy Mays wrote: > I'll probably get flak for this, but damn the torpedoes: > > def my_int(num): > import re > try: > m = re.match('^(-?[0-9]+)(.0)?$', num) > return int(m.group(1))
As a toy for learning about regexes, that's fine, but I trust you would never use that in production. There are less verbose ways of wasting time and memory. > except AttributeError: > #raise your own error, or re raise > raise "except Foo: raise" is pointless; a bare raise is only useful if you need to do something before, or instead of, re-raising the current exception. try: boil(kettle) except HeatingError: if isempty(kettle): kettle.fill(water) boil(kettle) else: raise Catching an exception only to unconditionally re-raise it is only good for generating more heat in the CPU and making other developers laugh at you :) -- Steven -- http://mail.python.org/mailman/listinfo/python-list