Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38336
| 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 | <rosuav@gmail.com> |
| 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> <ker11p$iii$1@reader1.panix.com> <kers04$1gi$2@news.albasani.net> <andcgpFbac1U1@mid.individual.net> <mailman.1393.1360102601.2939.python-list@python.org> <kes2u6$q6n$2@reader1.panix.com> <mailman.1396.1360107343.2939.python-list@python.org> <5111b826$0$29969$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmo6yvH6xySfDCK3T7MtwinzDPe6KDwOR+Wusb3WfsD+kQ@mail.gmail.com> <mailman.1423.1360172253.2939.python-list@python.org> <5112eb4a$0$29965$c3e8da3$5496439d@news.astraweb.com> <mailman.1438.1360214905.2939.python-list@python.org> <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 <rosuav@gmail.com> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1441.1360223398.2939.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
On Thu, Feb 7, 2013 at 5:50 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> 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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Opinion on best practice... Anthony Correia <akcorreia@gmail.com> - 2013-02-04 20:14 -0800
Re: Opinion on best practice... Michael Torrie <torriem@gmail.com> - 2013-02-04 23:04 -0700
Re: Opinion on best practice... Terry Reedy <tjreedy@udel.edu> - 2013-02-05 02:56 -0500
Re: Opinion on best practice... Grant Edwards <invalid@invalid.invalid> - 2013-02-05 13:23 +0000
Re: Opinion on best practice... Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-02-05 08:56 +0100
Re: Opinion on best practice... Peter Otten <__peter__@web.de> - 2013-02-05 11:35 +0100
Re: Opinion on best practice... Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-02-05 14:05 +0100
Re: Opinion on best practice... Grant Edwards <invalid@invalid.invalid> - 2013-02-05 13:22 +0000
Re: Opinion on best practice... Walter Hurry <walterhurry@lavabit.com> - 2013-02-05 21:01 +0000
Re: Opinion on best practice... Neil Cerutti <neilc@norwich.edu> - 2013-02-05 21:39 +0000
Re: Opinion on best practice... Ethan Furman <ethan@stoneleaf.us> - 2013-02-05 14:07 -0800
Re: Opinion on best practice... Grant Edwards <invalid@invalid.invalid> - 2013-02-05 23:00 +0000
Re: Opinion on best practice... Chris Angelico <rosuav@gmail.com> - 2013-02-06 10:35 +1100
Re: Opinion on best practice... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-06 12:55 +1100
Re: Opinion on best practice... Dan Stromberg <drsalists@gmail.com> - 2013-02-05 18:14 -0800
Re: Opinion on best practice... Chris Angelico <rosuav@gmail.com> - 2013-02-06 17:16 +1100
Re: Opinion on best practice... rusi <rustompmody@gmail.com> - 2013-02-05 23:32 -0800
Re: Opinion on best practice... Grant Edwards <invalid@invalid.invalid> - 2013-02-06 15:18 +0000
Re: Opinion on best practice... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-06 12:37 -0500
Re: Opinion on best practice... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-07 10:46 +1100
Re: Opinion on best practice... Chris Angelico <rosuav@gmail.com> - 2013-02-07 16:28 +1100
Re: Opinion on best practice... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-07 06:50 +0000
Re: Opinion on best practice... Chris Angelico <rosuav@gmail.com> - 2013-02-07 18:49 +1100
Re: Opinion on best practice... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-08 09:49 +1100
Re: Opinion on best practice... Chris Angelico <rosuav@gmail.com> - 2013-02-08 17:54 +1100
Re: Opinion on best practice... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-08 12:41 -0500
Re: Opinion on best practice... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-07 13:54 -0500
Re: Opinion on best practice... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-08 09:58 +1100
Re: Opinion on best practice... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-08 13:29 -0500
Re: Opinion on best practice... Chris Angelico <rosuav@gmail.com> - 2013-02-09 11:28 +1100
Re: Opinion on best practice... John Ladasky <john_ladasky@sbcglobal.net> - 2013-02-08 19:10 -0800
Re: Opinion on best practice... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-06 00:33 -0500
Re: Opinion on best practice... Anssi Saari <as@sci.fi> - 2013-02-06 15:30 +0200
Re: Opinion on best practice... Grant Edwards <invalid@invalid.invalid> - 2013-02-05 22:59 +0000
Re: Opinion on best practice... Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-05 17:05 -0700
Re: Opinion on best practice... Grant Edwards <invalid@invalid.invalid> - 2013-02-06 15:04 +0000
Re: Opinion on best practice... Neil Cerutti <neilc@norwich.edu> - 2013-02-06 14:20 +0000
Re: Opinion on best practice... Grant Edwards <invalid@invalid.invalid> - 2013-02-06 15:11 +0000
Re: Opinion on best practice... Nobody <nobody@nowhere.com> - 2013-02-06 03:32 +0000
Re: Opinion on best practice... Michael Torrie <torriem@gmail.com> - 2013-02-05 22:07 -0700
csiph-web