Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'assign': 0.07; 'attributes': 0.09; 'function,': 0.09; 'function:': 0.09; 'parameter': 0.09; 'subject:module': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; '24,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inclined': 0.16; 'lambda': 0.16; 'responses.': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'module': 0.19; 'replacing': 0.19; 'cc:addr:python.org': 0.22; 'certainly': 0.24; 'cc:2**0': 0.24; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message- id:@mail.gmail.com': 0.30; 'are.': 0.31; 'probably': 0.32; "i'd": 0.34; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'pm,': 0.38; 'simple': 0.61; 'first': 0.61; 'name': 0.63; 'worth': 0.66; 'mar': 0.68; '2015': 0.84; 'here)': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=RCkYeQuA3k0+GTqkIIMFY0iMGKFJKm1txReDwS1jG7w=; b=GkfKcwJ3dSQnJAYz/iFVetufmhmhZMZZbnLRUVzA2oJQPDSkYf2RYqG3Z3KCTfSsNM HzNXrUBrBhdU9FSJHYTPMeEeoOSeZMlEeAeXh8I4pOzgKTf4oExBPskSysIcrEj4qXnD KCWJ3pi71pZsSK4UTups4u8Edxlm2RcOWUNp16UjZXkwnhMC7CePqDzEyc4HwQFall0e PP95+Rq/j/1qG59NHZ0RTLj+h7POZ0z2+QZRbhInNnpiIJot6Ezu+u4XGTm8tM0ODxwl HraKX7/MUMduHw3TsYD7AgogrSGXSjUSwItBht9kZ4Qw4oTZAsklT8IJc3v84Kam1MBB UYZQ== MIME-Version: 1.0 X-Received: by 10.107.160.212 with SMTP id j203mr5162107ioe.43.1427192984726; Tue, 24 Mar 2015 03:29:44 -0700 (PDT) In-Reply-To: References: Date: Tue, 24 Mar 2015 21:29:44 +1100 Subject: Re: module attributes and docstrings From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1427192988 news.xs4all.nl 2923 [2001:888:2000:d::a6]:43854 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87877 On Tue, Mar 24, 2015 at 7:55 PM, Mario Figueiredo wrote: > 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, or document attributes in the module docstring. They > are fair responses. They certainly are. Any time you assign a lambda function directly to a simple name, it's probably worth replacing with a def function: def value_factory(_, row): """Row factory. To be used with single-column queries.""" return row[0] (Though I'd be inclined to give the first parameter a proper name here) ChrisA