Path: csiph.com!usenet.pasdenom.info!bete-des-vosges.org!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1a.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'programmer': 0.03; 'suddenly': 0.07; 'tries': 0.07; 'converted': 0.09; 'filter,': 0.09; 'function,': 0.09; 'helping.': 0.09; 'overflow': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'useful,': 0.14; "wouldn't": 0.14; 'does,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'help...': 0.16; 'lisp,': 0.16; 'q&a': 0.16; 'trivially': 0.16; 'worst': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'stack': 0.19; 'unlike': 0.19; 'starts': 0.20; 'cc:addr:python.org': 0.22; 'mind.': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'push': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'towards': 0.31; 'anyone': 0.31; 'says': 0.33; 'there,': 0.34; 'maybe': 0.34; 'problem': 0.35; 'common': 0.35; 'knows': 0.35; 'no,': 0.35; 'point.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'building': 0.35; 'really': 0.36; 'doing': 0.36; 'next': 0.36; 'useful': 0.36; 'so,': 0.37; 'list': 0.37; 'filter': 0.38; 'expect': 0.39; 'explain': 0.39; 'either': 0.39; 'even': 0.60; 'then,': 0.60; 'worry': 0.60; 'most': 0.60; 'forum': 0.61; 'helps': 0.61; 'new': 0.61; 'no.': 0.61; 'simply': 0.61; "you're": 0.61; 'map': 0.64; 'teaching': 0.64; 'more': 0.64; 'between': 0.67; 'mar': 0.68; 'reads': 0.68; 'online': 0.71; '2015': 0.84; 'complexity': 0.84; 'etc,': 0.84; 'studying': 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=IbnvUHMoibpjnIiqosQ/gQueF3i8QoKc2b3arTSkqVg=; b=s1udqC6A6DTufa1pfakNr2E/lD/RiAcFGD+lKXGFpAc+UTc85CbG+te3gU6rFi9exJ 8qVlJ2aAb4DdyvyX0PQOWAGAukoVNTqPWVi0o5D7y8ZwaU3C/n/BTpLkwptXU/T8uGn7 P9xrNoJWP5oaKwjVnkyy4dHijc36VYEz1A5KPqLa/1udRZrNmK02u8GJWEnb/ft4iabS O0OWJrHQhv+YTxRvoLclEm5Cwm0y9USzg+1eK3LcnXqVcLeSFZ3cFMxyTN/iAkg1OIBE /7ogyr9WazRBGlH5b3frjCwfuG6BUa8UJmfXP1+9x/4G4M/25xbx+5Vegi1ICYJURlhM Vhlw== MIME-Version: 1.0 X-Received: by 10.50.61.175 with SMTP id q15mr45422499igr.34.1427465832639; Fri, 27 Mar 2015 07:17:12 -0700 (PDT) In-Reply-To: <1a8eccd0-50d7-4eb3-84ec-5c7bbdb34b89@googlegroups.com> References: <87bnjhyohp.fsf@uriel.graune.org> <9b6f41d0-e27e-4e0b-b04d-d15627667330@googlegroups.com> <5514ddee$0$12979$c3e8da3$5496439d@news.astraweb.com> <1a8eccd0-50d7-4eb3-84ec-5c7bbdb34b89@googlegroups.com> Date: Sat, 28 Mar 2015 01:17:12 +1100 Subject: Re: Supply condition in function call 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: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1427465834 news.xs4all.nl 2964 [2001:888:2000:d::a6]:54388 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88164 On Sat, Mar 28, 2015 at 12:48 AM, Rustom Mody wrote: > Knows some C, not much else. > Starts studying python. > Good until a point. > Then suddenly hit... map, filter, and the worst of all lambda. > More he reads less he understands. > Tries help... Gets the above. > > So which do you think helps him more python 2 or 3? Python 3, because scaring someone off filter() might push him towards comprehensions instead :) No, seriously: I wouldn't expect anyone to be using help(filter) in that way. Someone who knows C and not much Python is simply not going to stumble upon filter, but will have a task/problem in mind. From there, either the online documentation or a Q&A forum like this or Stack Overflow will be the next port of call, not the help for one particular function. And frankly, if someone says "what you want is filter()" and doesn't explain what it does, why it's useful, and why it's better than a list comp/genexp, is doing a poor job of helping. The most common case of filter can be trivially converted into a genexp: filter(lambda x: some_expression, some_iterable) (x for x in some_iterable if some_expression) Unlike map(), filter() doesn't accept multiple iterables, so you don't even need to worry about zip(). The only time you really need filter() is when you're using a pre-existing function, and even then, a genexp is often not much worse: filter(int, list_of_strings) (s for s in list_of_strings if int(s)) Instead of building up more and more complex nestings of map, filter, etc, just go straight to a genexp (or a list comp, if you're about to wrap it in list()) and add the complexity you need. Teaching a new Python programmer about comprehensions is MUCH more useful than teaching him/her about map and filter. So, no. I don't think the help() difference between Py2 and Py3 is going to be much of a problem to a new programmer who knows only C. Maybe one who knows only LISP, but not one who knows C. ChrisA