Path: csiph.com!news.swapon.de!weretis.net!feeder1.news.weretis.net!news.roellig-ltd.de!open-news-network.org!border2.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:code': 0.07; 'utf-8': 0.07; 'works.': 0.07; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; '-1,': 0.09; 'arg': 0.09; 'arg,': 0.09; 'received:mail-wi0-x233.google.com': 0.09; 'python': 0.10; 'def': 0.13; 'argument': 0.15; 'subject: \n ': 0.15; 'calculates': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'first,': 0.20; 'arguments': 0.22; 'cc:no real name:2**0': 0.22; 'sat,': 0.23; 'this:': 0.23; 'header :In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; '-0700,': 0.29; 'ronald': 0.29; 'subject:that': 0.29; 'another': 0.32; 'generally': 0.32; 'point,': 0.33; 'list': 0.34; 'received:google.com': 0.35; 'there': 0.36; 'subject:: ': 0.37; 'skip:p 20': 0.38; 'hi,': 0.38; 'called': 0.40; 'your': 0.60; "you'll": 0.61; 'subject:. ': 0.67; 'subject:have': 0.80; '3...': 0.84; 'function)': 0.84; 'simple:': 0.84; 'subject:calls': 0.84; 'received:hu': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=s5ULDpclYVEFuMSDt1VS4BG9tXTYZXIb7UDPMx7AVtw=; b=wO6rdU2hOiP0MSUjtto6XXBpFtYM5hQmVXVsQ7k2JSw37Qa7o5Aw+uq7ncpKp5hgh6 qJ50bhu8i9XA6RbNtL+OQfGChNiq6/bsW9VbCR7Yet7pEemAWBWvtPzJv3Wh9yslv63+ CV5Sb2HFi7zgKO9iM7ugSLGwl3mQdgMz859T8AkGlvMEyZCGwgKEvo2wf6qKbAoOSE50 iWcivrvLHsMV03tqjfhmEEHwiJfGr18Rs88skeCoFjWELBJ/A4g8JLjSPQwHGKSIAvp3 CvuSruk4ws2Jj6/ZjKuBPd/GXaBvhzs5WT5BcYDsYsqecNIZyEg6SfrwHKzvdBo3jtaI H0Ow== X-Received: by 10.180.24.102 with SMTP id t6mr3617234wif.83.1443895786648; Sat, 03 Oct 2015 11:09:46 -0700 (PDT) Date: Sat, 3 Oct 2015 20:09:43 +0200 From: Ervin =?utf-8?Q?Heged=C3=BCs?= To: Ronald Cosentino Cc: python-list@python.org Subject: Re: function code snippet that has function calls I have never seen before. How does it work. References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1443895792 news.xs4all.nl 23734 [2001:888:2000:d::a6]:55240 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:97385 hi, On Sat, Oct 03, 2015 at 10:40:57AM -0700, Ronald Cosentino wrote: > def funA(x,y,z): > return (x+y) * z > def funB(x,y): > return(x-y) > print(funA(4,funB(2,3), funB(3,2))) > > the answer is 3. I don't know how it works. it's simple: - there is a "composition of functions", generally f(g()) (function in argument list of another function) - first, Python evaulates the arguments first, from left to right - in this point, you'll get -1 for 2nd arg, and 1 for 3rd arg - then your funcA() will be called with these arguents: 4, -1, 1 - funcA() calculates this: (x+y)*z, in this case (4+(-1))*1 which is 3... a. -- I � UTF-8