Bugs item #672578, was opened at 2003-01-22 17:29 Message generated for change (Comment added) made by wamcvey You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=672578&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Demos and Tools Group: Python 2.2.1 Status: Closed Resolution: Fixed Priority: 5 Submitted By: Jim Meyer (purp) Assigned to: Nobody/Anonymous (nobody) Summary: pydoc does not cope well with lambda Initial Comment: pydoc doesn't deal well with lambda expressions. Here's some sample code: ================================================================ #!/usr/bin/env python2 """a bogus program Demonstrate that pydoc doesn't handle lambdas well """ # -------------------------------------------------------------------- # A comment heading # -------------------------------------------------------------------- def foo (optional = 1) : ''' A bogus function ''' return optional bar = lambda opt : foo(opt) ================================================================ ...and here's what pydoc says: ================================================================ > pydoc /tmp/foo.py Python Library Documentation: module foo NAME foo - a bogus program FILE /tmp/foo.py DESCRIPTION Demonstrate that pydoc doesn't handle lambdas well FUNCTIONS lambdaopt # -------------------------------------------------------------------- # A comment heading # -------------------------------------------------------------------- foo(optional=1) A bogus function DATA __file__ = '/tmp/foo.pyc' __name__ = 'foo' ================================================================ I'm looking for the cause now and hope to contribute a patch shortly. --j ---------------------------------------------------------------------- Comment By: William McVey (wamcvey) Date: 2006-02-14 17:14 Message: Logged In: YES user_id=25956 This problem still appears to exist under python 2.4.2 drop the following into PydocLambdaTest.py and run 'pydoc PydocLambdaTest': #!/usr/bin/env python """Simple test cases for doc strings attached to lambda generated functions and methods """ def test_function(x, y): """This is a test function doc string""" pass test_lambda = lambda x, y: True test_lambda2 = lambda x, y: True test_lambda2.__doc__ = "This is a docstring on a lambda function" class TestClass: def test_method(self, x, y): """Just a docstring on a method""" pass sum = lambda self, x, y: x+y mult = lambda self, x, y: x*y mult.__doc__ = "Multiplies the two arguments " if __name__ == '__main__': obj = TestClass() print "sum of 5 and 7:", obj.sum(5, 7) print "mult of 5 and 7:", obj.mult(5, 7) ---------------------------------------------------------------------- Comment By: Raymond Hettinger (rhettinger) Date: 2003-01-23 01:55 Message: Logged In: YES user_id=80475 The underlying cause is that the inspect module was not trained to handle lambdas or single line function defintions like: def oneliner(x): return x**2 The problem was fixed in Py2.3 and backported for Py2.2.3. Marking as fixed and closing. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=672578&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com