Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'explicitly': 0.04; 'ignored': 0.05; 'executed': 0.07; 'python': 0.09; '"if': 0.09; '-rf': 0.09; 'def': 0.10; 'expression,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'naming': 0.16; 'parentheses': 0.16; 'rule.': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'accepting': 0.18; 'feb': 0.19; 'code.': 0.20; 'putting': 0.20; 'sort': 0.21; 'suddenly': 0.22; "python's": 0.23; 'header:In- Reply-To:1': 0.25; 'values': 0.26; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'chris': 0.28; "d'aprano": 0.29; 'steven': 0.29; 'function': 0.30; 'code': 0.31; 'right?': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'desirable': 0.35; 'pm,': 0.35; 'too.': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'anything': 0.36; 'should': 0.36; 'execute': 0.37; 'does': 0.37; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'subject:...': 0.63; 'choose': 0.65; '2013': 0.84; 'rexx,': 0.84; 'safe.': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=jEfbjqN4noXxR1UDFOKrh5efRV2hF0nceezJI79KSVk=; b=bq6esw/F6KHD+6pltFPqvqPwOuXEXfBrRCM4J4FDsu6cRjJPTuKhxmglnU+69g+Vp3 8zZXJPZggkwH1yRcnq8jtu5OuPUaN2GNu4QbrMz9MTb1MJv65GY5dEwQ7ucgUVkRPT3c QmuC/l2V+o5pgKDpTQdV/H1YWU6uybMj7ZXtixyDS5grXHmgYmfR+sl4TWYtdw7+Knh/ dcixlcCYmHG9cPmbI/VswOs1a2oQsPPpMPY9PNtal27FPzdloWGLEjbqALxRfUte70rV lb9I2BL0DjriBc3tOVvlp7dvEN2iLeVZJGCM+nhZHUXLU6qekGxzkCSiUHMgMvYmIYKy jnSQ== MIME-Version: 1.0 X-Received: by 10.52.29.109 with SMTP id j13mr300914vdh.111.1360223389723; Wed, 06 Feb 2013 23:49:49 -0800 (PST) In-Reply-To: <51134e9f$0$21812$c3e8da3$76491128@news.astraweb.com> References: <207d17ce-4bc7-487c-acde-6a7b9f66002b@googlegroups.com> <5111b826$0$29969$c3e8da3$5496439d@news.astraweb.com> <5112eb4a$0$29965$c3e8da3$5496439d@news.astraweb.com> <51134e9f$0$21812$c3e8da3$76491128@news.astraweb.com> Date: Thu, 7 Feb 2013 18:49:49 +1100 Subject: Re: Opinion on best practice... From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360223398 news.xs4all.nl 6869 [2001:888:2000:d::a6]:52151 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38336 On Thu, Feb 7, 2013 at 5:50 PM, Steven D'Aprano wrote: > On Thu, 07 Feb 2013 16:28:17 +1100, Chris Angelico wrote: > >> You misunderstand. It's actually a very simple rule. Python follows C's >> principle of accepting that any return value from an expression should >> be ignored if you don't do anything with it. > > Return values are safe. They don't do anything, since they are *being > ignored*, not being executed as code. You have to explicitly choose to do > something with the return value before it does anything. > > If C said "if you don't do anything with the return result of an > expression, execute it as code in the shell", would you consider that a > desirable principle to follow? > > def oh_my_stars_and_garters(): > return "rm -rf /" > > oh_my_stars_and_garters() Naming a function is safe, too. def earth_shattering(): os.system("rm -rf /") earth_shattering; But putting parentheses after it suddenly makes it dangerous. Wow! Python's pretty risky, right? In REXX, you simply don't *do* that sort of thing. (You'd use the CALL statement, for instance.) ChrisA