Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.030 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'syntax': 0.04; 'permitted': 0.07; 'subject:script': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; '__future__': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hmm.': 0.16; 'mode,': 0.16; 'repl': 0.16; 'script,': 0.16; 'subject:run': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.18; 'bit': 0.19; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'instance,': 0.24; 'environment': 0.24; 'cc:2**0': 0.24; 'define': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'feature': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'running': 0.33; '(e.g.': 0.33; 'fri,': 0.33; 'subject:from': 0.34; 'something': 0.35; 'more,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'in.': 0.36; 'useful': 0.36; 'subject:?': 0.36; 'pm,': 0.38; 'that,': 0.38; 'bad': 0.39; 'sure': 0.39; 'future': 0.60; 'is.': 0.60; 'new': 0.61; 'simply': 0.61; "you're": 0.61; 'making': 0.63; 'more': 0.64; 'different': 0.65; '30,': 0.65; 'anything.': 0.68; 'invalid': 0.68; 'promise': 0.68; 'legal': 0.71; 'special': 0.74; 'introduce': 0.78; 'beats': 0.84; 'parser,': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=PaK2b5jOqZwyR8r1o2CZ8fmvUYaD4VOQXL7OV7HK/3k=; b=sp+yIuR+djhh9aujN+u1rf2lTfkdD0O29JAJ72Bjn16KZxcCjVFNr9nophGaOF7asY 50R3HRMH/sUu6fE4yFLDIzq7JqhHxlHwcMm4XKc4C9niHRey+G2X7LcUYSwLPFTux8nF DAIF9XTJ+xt8L+vsz/rFpuHYhQd+rgQE68eqDv3OHyDnJCIZhI3L73J3QHdc0cNJ1Ms7 uUfkPFJEAzZN8qxUVhtWRjJt+v2b0P85gfzUtKE0r8CCQjj/QfJVIRrz3qc90E9dkJVa QhqapsQalZuxTh4PxhmZaYl143M98Vubn/fUKFUgKgjygcegShPVHBy3QpduyIMm9S/m GFDA== MIME-Version: 1.0 X-Received: by 10.58.85.65 with SMTP id f1mr13303047vez.20.1401450415944; Fri, 30 May 2014 04:46:55 -0700 (PDT) In-Reply-To: <53886b1e$0$29978$c3e8da3$5496439d@news.astraweb.com> References: <6e96c4c4-17db-464b-b291-816c534b70c4@googlegroups.com> <5386a7e2$0$11109$c3e8da3@news.astraweb.com> <5387d1c4$0$29978$c3e8da3$5496439d@news.astraweb.com> <5387e3b1$0$29978$c3e8da3$5496439d@news.astraweb.com> <5388233e$0$29978$c3e8da3$5496439d@news.astraweb.com> <53886b1e$0$29978$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 30 May 2014 21:46:55 +1000 Subject: Re: How to run script from interpreter? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1401450424 news.xs4all.nl 2883 [2001:888:2000:d::a6]:38543 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72293 On Fri, May 30, 2014 at 9:27 PM, Steven D'Aprano wrote: > This is why I'm so adamant that, while REPLs may be permitted to > introduce *new* syntax which is otherwise illegal to the Python parser, > (e.g. like IPython's %magic and !shell commands) they *must not* change > the meaning of otherwise legal Python syntax. It's simply a bad idea to > have legal Python code mean different things depending on what > environment you're running it in. Hmm. I'm not sure that "raises SyntaxError" is any less a part of the language's promise than "evaluates to twice the value of x" is. Would you, for instance, permit the REPL to define a new __future__ directive, on the basis that it's invalid syntax currently? >>> from __future__ import magic_command_history SyntaxError: future feature magic_command_history is not defined I don't think SyntaxError equates to "invitation to make changes". Also, consider: >>> for i in range(5): i*3+2 2 5 8 11 14 If you do this in a script, it's perfectly legal, but won't print anything. So the REPL is already "chang[ing] the meaning of otherwise legal Python syntax", and what's more, it's making None into a special case: >>> for i in range(5): None if i%2 else i 0 2 4 Practicality beats purity. If it's more useful to the end user for something valid-but-illogical to have a new bit of meaning in interactive mode, I say go for it. ChrisA