Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '+++': 0.03; 'syntax': 0.03; 'value,': 0.03; 'string.': 0.04; 'python': 0.09; '"if': 0.09; "'n'": 0.09; '-rf': 0.09; 'executes': 0.09; 'filename,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'throw': 0.09; 'def': 0.10; "wouldn't": 0.11; 'language': 0.14; 'bash,': 0.16; 'command,': 0.16; 'command;': 0.16; 'echo': 0.16; 'equivalents': 0.16; 'executed.': 0.16; 'explicitly,': 0.16; 'expression,': 0.16; 'expressions.': 0.16; 'illustrate': 0.16; 'naming': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'statement;': 0.16; 'syntax.': 0.16; 'unquoted': 0.16; 'string': 0.17; 'string,': 0.17; 'saying': 0.18; 'shell': 0.18; 'windows': 0.19; 'feb': 0.19; 'file.': 0.20; 'error.': 0.21; 'produces': 0.22; 'external': 0.24; 'command': 0.24; 'creating': 0.26; 'values': 0.26; 'language.': 0.27; 'plain': 0.27; 'recognized': 0.27; 'execution': 0.27; 'label': 0.27; 'header:X-Complaints- To:1': 0.28; 'lines': 0.28; 'closer': 0.29; "d'aprano": 0.29; 'steven': 0.29; 'basic': 0.30; 'function': 0.30; 'code': 0.31; 'could': 0.32; 'function.': 0.33; 'quotes': 0.33; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'text': 0.34; 'desirable': 0.35; 'received:org': 0.36; 'but': 0.36; "didn't": 0.36; 'anything': 0.36; 'charset:us-ascii': 0.36; 'execute': 0.37; 'does': 0.37; 'passed': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'description': 0.39; 'to:addr:python.org': 0.39; 'called': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'subject:...': 0.63; 'making': 0.64; '2013': 0.84; 'them;': 0.84; 'dennis': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Opinion on best practice... Date: Thu, 07 Feb 2013 13:54:39 -0500 Organization: > Bestiaria Support Staff < References: <5111b826$0$29969$c3e8da3$5496439d@news.astraweb.com> <5112eb4a$0$29965$c3e8da3$5496439d@news.astraweb.com> <51134e9f$0$21812$c3e8da3$76491128@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-253-109-163.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES 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: 88 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360263294 news.xs4all.nl 6926 [2001:888:2000:d::a6]:44642 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38359 On 07 Feb 2013 06:50:07 GMT, Steven D'Aprano declaimed the following in gmane.comp.python.general: > 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() > Return values wouldn't be sent to the shell... The function call was parseable as language syntax. > > Are you saying that Dennis' description of REXX sending unparsable text > to the shell for execution is incorrect? E:\UserData\Wulfraed\My Documents>type test.rx /* */ say time('n') 'say' time('n') echo time('n') 'echo' time('n') 'echo' "time('n')" echo "time('n')" what = 'ho' 'ec' || what time('n') ec || what time('n') time('n') say Now Calling "time()" call time 'n' say "time() was called" E:\UserData\Wulfraed\My Documents>regina test.rx 13:50:06 'say' is not recognized as an internal or external command, operable program or batch file. 3 *-* 'say' time('n') +++ RC=1 +++ 13:50:06 13:50:06 time('n') time('n') 13:50:06 13:50:06 The filename, directory name, or volume label syntax is incorrect. 11 *-* time('n') +++ RC=1 +++ NOW CALLING time() time() was called E:\UserData\Wulfraed\My Documents> Line 1 (treating the /**/ as line 0) is the REXX "say" command, outputting the result of calling the REXX time() function. Line 2 quotes the "say", making it a string, and not a parseable REXX statement; Windows command shell produces an error. Line 3 has unquoted "echo" which is not a REXX command; it is considered an external command and is passed the /result/ of calling REXX time() -- where Windows executes it Line 4 quotes "echo" but is otherwise the same Lines 5 and 6 quote the "time()" call -- making that a string. Lines 7-9 illustrate creating lines from string expressions. Line 10 is treating the result of an internal function as the command to be executed. So yes, REXX does not throw away function return values -- you must catch them; if you don't want the return value, then you need to "call" the function explicitly, shown in lines 11-13. Plain REXX didn't have equivalents to "import", but could call "subprograms" by just naming them on a statement... Making REXX closer to BASH, cmd.exe, PowerShell, VMS DCL... Whereas Python is closer to BASIC -- a byte-code compiled/interpreted language. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/