Path: csiph.com!goblin3!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:code': 0.07; 'works.': 0.07; 'subject:How': 0.09; 'before.': 0.09; 'snippet': 0.09; 'def': 0.13; 'argument': 0.15; 'message-----': 0.15; 'callee': 0.16; 'skip:[ 60': 0.16; '(in': 0.18; '2015': 0.20; 'first,': 0.20; 'to:2**1': 0.21; 'function,': 0.22; 'cheers,': 0.22; 'thus': 0.24; 'header:In-Reply-To:1': 0.24; 'function': 0.28; 'ronald': 0.29; 'subject:that': 0.29; 'print': 0.30; 'url:mailman': 0.30; 'work.': 0.30; 'code': 0.30; 'another': 0.32; 'url:python': 0.33; 'message-id:@gmail.com': 0.34; 'skip:- 10': 0.34; 'url:listinfo': 0.34; 'case,': 0.34; 'received:google.com': 0.35; 'sent:': 0.35; 'returning': 0.35; 'subject:': 0.35; 'step': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'charset:us- ascii': 0.37; 'itself': 0.38; 'skip:p 20': 0.38; 'does': 0.39; 'takes': 0.39; 'from:': 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'saturday,': 0.63; 'python-list': 0.66; 'results': 0.66; 'email name:python-list': 0.67; 'subject:. ': 0.67; 'subject:have': 0.80; 'subject:calls': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:references:in-reply-to:subject:date:message-id:mime-version :content-type:content-transfer-encoding:thread-index :content-language; bh=or3K1dHO8cPbudHZX9zvJT+ywqwXo8nY3PqFgyMmCQY=; b=Wm4UZZcTdfNmeR5qorL743J7Pbk0N5yHlHIJP3AymLQrOBwRn0hL3i02kDjbfRrylW tiKOCBLKPEqtwEOTUNCpQeBR+90ZznxOkohU/s2kCpDq5YZu+dOolQ59QoFpITjSs7gr RuL8tZCH+9s7XBrgl/Ac6ECrBG1lKCQuTY3xH3bkMgVwOsfDWs6WBe6YTarmj30sNxO3 3OZIUHYUJ0cChXrHYZi9BKwkZPG31tnMSoLFFTYtLRsJ2uWrD+Xplgo8CFPXFYafyp28 A4gLENfbbklnKglZva8y9iPvO1RBPMVRi5Cr0U6D+F0bjakwTYGp4dHUgB0q5CNNCIQG 1Czg== X-Received: by 10.66.232.40 with SMTP id tl8mr27385203pac.45.1443895393647; Sat, 03 Oct 2015 11:03:13 -0700 (PDT) From: "Joseph Lee" To: "'Ronald Cosentino'" , References: In-Reply-To: Subject: RE: function code snippet that has function calls I have never seen before. How does it work. Date: Sat, 3 Oct 2015 11:03:07 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQIrU82q+dlEP3gdIOH8/dUmUhPD6Z2lYSKg Content-Language: en-us 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1443895403 news.xs4all.nl 23800 [2001:888:2000:d::a6]:51845 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:97384 Hi Ronald, Answers inline. -----Original Message----- From: Python-list [mailto:python-list-bounces+joseph.lee22590=gmail.com@python.org] On Behalf Of Ronald Cosentino Sent: Saturday, October 3, 2015 10:41 AM To: python-list@python.org Subject: function code snippet that has function calls I have never seen before. How does it work. 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. JL: Okay, let's step through the print routine. 1. Before print does its job, the function result will be gathered. 2. The argument to print is result of funA, which itself takes result of two calls to FunB. 3. First, results of funB calls will be gathered (subtracting 3 from 2 and 2 from 3, respectively). So it becomes: print(funA(4, (2-3), (3-2))) 4. Then funA will continue to perform its job, returning the result for output. Thus the final expression that print will print is: print((4+-1) * 1) When looking at a function that takes result of another function, it is important to look at what the inner callee does (in this case, look at what funB does first). Cheers, Joseph -- https://mail.python.org/mailman/listinfo/python-list