While playing around with the inspect module I found that the Blockfinder doesn't recognize single line function definitions.
Adding the following two lines to it fixes it, but I'm not sure if it causes any problems anywhere else. elif self.indent == 0: raise EndOfBlock, self.last Cheers, Ron C:\Python24\Lib>diff.py inspect.py inspect_.py *** inspect.py Tue Mar 15 13:22:02 2005 --- inspect_.py Mon Sep 19 14:26:26 2005 *************** *** 531,536 **** --- 531,538 ---- raise EndOfBlock, self.last elif type == tokenize.NAME and scol == 0: raise EndOfBlock, self.last + elif self.indent == 0: + raise EndOfBlock, self.last def getblock(lines): """Extract the block of code at the top of the given list of lines.""" def test(t): print '**',t,'**' print "Line:" def f(): pass """ This line shouldn't be visible """ print inspect.getsource(f) print "Block:" def f(): pass pass """This line should not be visible.""" print inspect.getsource(f) import inspect test("before") import inspect_ as inspect test("after") #-- output -- ** before ** Line: def f(): pass """ This line shouldn't be visible """ print inspect.getsource(f) print "Block:" def f(): pass pass Block: def f(): pass pass ** after ** Line: def f(): pass Block: def f(): pass pass -- http://mail.python.org/mailman/listinfo/python-list