Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'assignment': 0.07; 'attribute': 0.07; 'attributes': 0.09; 'function,': 0.09; 'latter': 0.09; 'pep': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:module': 0.09; 'def': 0.12; 'jan': 0.12; 'lambda': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'statement.': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'module': 0.19; 'header:User-Agent:1': 0.23; 'possibly': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'specifically': 0.29; 'am,': 0.29; 'statement': 0.30; 'object.': 0.31; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'impression': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'expression': 0.60; 'advantages': 0.68; 'discovered': 0.83; '257': 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: module attributes and docstrings Date: Tue, 24 Mar 2015 15:33:41 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-98-114-97-173.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1427225646 news.xs4all.nl 2873 [2001:888:2000:d::a6]:45927 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87895 On 3/24/2015 4:55 AM, Mario Figueiredo wrote: > Reading PEP 257 and 258 I got the impression that I could document > module attributes and these would be available in the __doc__ > attribute of the object. > > So things like the one below are something I got used to do, but that > don't work after all, as I learned today: > > value_factory = lambda _, row: row[0] > """Row factory. To be used with single-column queries.""" > > There are other things I could possibly do, like turning that lambda > into a function, You have discovered one of advantages of a def statement over a name=lambda assignment statement. In Python, there is no good reason to use the latter form and PEP 8 specifically discourages it: "Always use a def statement instead of an assignment statement that binds a lambda expression directly to an identifier." -- Terry Jan Reedy