Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88040
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'argument': 0.05; 'explicit': 0.07; 'assigning': 0.09; 'benefits,': 0.09; 'function,': 0.09; 'subject:module': 0.09; 'translate': 0.10; 'cc:addr:python-list': 0.11; 'times,': 0.14; 'declaration': 0.16; 'def.': 0.16; 'expression,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lambda': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'widget': 0.19; 'rules': 0.22; 'cc:addr:python.org': 0.22; 'skip:l 30': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'room': 0.29; "doesn't": 0.30; 'document.': 0.30; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'implicit': 0.31; 'obscure': 0.31; 'really,': 0.31; 'skip:d 20': 0.34; 'basic': 0.35; 'agree': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'two': 0.37; 'list': 0.37; 'pm,': 0.38; 'ability': 0.39; 'either': 0.39; 'read': 0.60; 'expression': 0.60; 'simple': 0.61; "you're": 0.61; 'name': 0.63; 'more': 0.64; 'spot': 0.65; 'mar': 0.68; '26,': 0.68; 'obvious': 0.74; '2015': 0.84; 'decorate': 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=AOojSKM4PdP2uh4sE0YWyoKAmF/Ec7fbfB04v1Mc/Bg=; b=m/5Aa2ZfyeARjCFtN019BNVVGrLQaSQ8sBZC8bHp8yVaL9ce8UkMIKjuGtjciZ1Abq 5JdmqMJQ+NlfVNQ+QuM5Z2Kf7z5aStZN6dmPkcP/xfZ2YtYDMr2A9+LYdIIb8FbSLKXV Y9HayrUhtU4Eh+0fIHvzzsRbephrPJY6s7mCTg7VQNALuyUHxzVhVKU/Ce8yN+YZuv/r J1vFwO7v+HIBLz84EzCjYrH06e5GcU3B9sml6pDNtleaHo0Vxnx9GWkejwn2j5YQQ5U5 lPdfHF9/0yn+K4Uct02BBslApMTpDBDbyjp3n1kxAMvaFIj1NCDauVFRjuuSTufMF8v4 5FXQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.42.238.140 with SMTP id ks12mr37331238icb.12.1427365665217; Thu, 26 Mar 2015 03:27:45 -0700 (PDT) |
| In-Reply-To | <cgl7hadtmma78b3g2617tr0f19897gm7tu@4ax.com> |
| References | <fg92halkvjecqedpogsmkov3o53f0i922b@4ax.com> <mailman.110.1427225646.10327.python-list@python.org> <cgl7hadtmma78b3g2617tr0f19897gm7tu@4ax.com> |
| Date | Thu, 26 Mar 2015 21:27:45 +1100 |
| Subject | Re: module attributes and docstrings |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <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 <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.193.1427365668.10327.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1427365668 news.xs4all.nl 2951 [2001:888:2000:d::a6]:36844 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:88040 |
Show key headers only | View raw
On Thu, Mar 26, 2015 at 8:53 PM, Mario Figueiredo <marfig@gmail.com> wrote: > However, lambda functions do read well in my mind and I find it hard > to spot where they obscure the code more than a function. So the > explicit vs. implicit part of the argument doesn't translate well with > me. I however agree that a function declaration brings other benefits, > like the ability to decorate or document. A function is a function is a function, so really, it's just a question of whether you create them with a statement (def) or an expression (lambda). Two basic rules of thumb: 1) If you're assigning a lambda function to a simple name, then you don't need it to be an expression, so use def. 2) If you're warping your function body to make it an expression, use def. Basically, look at the outside and look at the inside. In some cases, it's obvious that it's all expressions: # Sort a list of widget objects by name widgets.sort(key=lambda w: w.name) Other times, it's pretty obvious that you should be using statements: delete_name_if_blank = lambda w: delattr(w, "name") if w.name == "" else None list(map(delete_name_if_blank, widgets)) In between, there's a lot of room to call it either way. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
module attributes and docstrings Mario Figueiredo <marfig@gmail.com> - 2015-03-24 09:55 +0100
Re: module attributes and docstrings Chris Angelico <rosuav@gmail.com> - 2015-03-24 21:29 +1100
Re: module attributes and docstrings Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-24 22:49 +1100
Re: module attributes and docstrings Mario Figueiredo <marfig@gmail.com> - 2015-03-26 10:48 +0100
Re: module attributes and docstrings Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-27 18:31 +1100
Re: module attributes and docstrings Marko Rauhamaa <marko@pacujo.net> - 2015-03-27 09:49 +0200
Re: module attributes and docstrings Terry Reedy <tjreedy@udel.edu> - 2015-03-24 15:33 -0400
Re: module attributes and docstrings Mario Figueiredo <marfig@gmail.com> - 2015-03-26 10:53 +0100
Re: module attributes and docstrings Chris Angelico <rosuav@gmail.com> - 2015-03-26 21:27 +1100
csiph-web