Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.054 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; '1000.': 0.09; '22,': 0.09; 'python': 0.11; 'times,': 0.14; 'interest,': 0.16; 'unlikely': 0.16; 'wrote:': 0.18; 'user.': 0.19; 'appears': 0.22; 'input': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'why.': 0.24; '(or': 0.24; 'sort': 0.25; 'first,': 0.26; 'least': 0.26; 'header :In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; "doesn't": 0.30; 'dec': 0.30; 'usually': 0.31; 'end,': 0.31; 'something': 0.35; 'case,': 0.35; 'but': 0.35; 'done,': 0.36; "i'll": 0.36; 'wrong': 0.37; 'to:addr:python-list': 0.38; 'fact': 0.38; 'pm,': 0.38; 'explain': 0.39; 'bad': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'ian': 0.60; 'mentioned': 0.61; 'matter': 0.61; 'pick': 0.64; 'received:74.208': 0.68; 'limit': 0.70; 'recursion,': 0.84; 'tricky': 0.84 Date: Mon, 22 Dec 2014 18:57:06 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Program calling unwanted functions References: <5498808D.60305@davea.name> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:7X8O6BjcJEKZiy+28dqyzMIAdxEpjaByt5y1GIiuDVd PTUxi4o3EOvL0vQrWiX+yUJJhTWFUmH1d3VBE8eJ2k7OMQpeno c4I8/I6JiLfHdXrWSsNu7Hmhj/PYfqXHl4ju0w219ULYwM370h AVafOSmBpzDcMw5AZKr894yZIfB2yS/YC2N3htguMSf0hOMUkU bOOdilpGuZyxRi6KLQNWmFB5niIku41U0KqSv5oQk/JUx6yF60 hsFv/Uje+3QIr5jMNDGFebopaQbGMK2UeBN79X1Bwz7tTcZGTp qscBXDD8TlIxWNS5RKVMp3uikJM19jygKYl7nvHaHAewZD4nw7 2uvHxpV4iFzu/95NOpWU= X-UI-Out-Filterresults: notjunk:1; X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1419292640 news.xs4all.nl 2855 [2001:888:2000:d::a6]:39406 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82818 On 12/22/2014 06:48 PM, Ian Kelly wrote: > On Dec 22, 2014 2:37 PM, "Dave Angel" wrote: >> >> I'll pick on one function first, called instructions(). If the user > types something invalid, you print "Invalid input." and call the function > again. In this case, because the call is at the end, no harm is usually > done, but it would be tricky to explain why. If the user happened to type > the wrong input 1000 times, you'd hit a recursion limit and crash, but > that's unlikely unless you have a very stubborn user. > > Point of interest, Python (or at least CPython) doesn't optimize tail-call > recursion, so in fact this sort of unbounded recursion (a "stack leak", if > you will) is equally bad no matter where it appears in the function. > Which is exactly why I mentioned the recursion limit of about 1000. -- DaveA