Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #72302

Re: How to run script from interpreter?

Path csiph.com!usenet.pasdenom.info!aioe.org!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'output': 0.05; '*not*': 0.07; '*is*': 0.09; 'latter': 0.09; 'parsing': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:script': 0.09; 'try:': 0.09; 'subject:How': 0.10; 'python': 0.11; 'jan': 0.12; 'hmm.': 0.16; 'minus': 0.16; 'mode,': 0.16; 'objects.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'repl': 0.16; 'script,': 0.16; 'shortcut': 0.16; 'subject:run': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.18; 'bit': 0.19; '>>>': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'adds': 0.24; 'script.': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'have,': 0.30; "i'm": 0.30; '>>>>': 0.31; 'breaking': 0.31; 'subject:from': 0.34; 'except': 0.35; 'something': 0.35; 'more,': 0.35; 'but': 0.35; 'raising': 0.36; 'useful': 0.36; 'subject:?': 0.36; 'to:addr :python-list': 0.38; 'rather': 0.38; 'does': 0.39; 'received:71': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'is.': 0.60; 'new': 0.61; 'course': 0.61; 'making': 0.63; 'real': 0.63; 'more': 0.64; 'anything.': 0.68; 'promise': 0.68; 'legal': 0.71; 'special': 0.74; 'beats': 0.84; 'execution.': 0.84; 'received:fios.verizon.net': 0.84; 'hand,': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: How to run script from interpreter?
Date Fri, 30 May 2014 11:24:11 -0400
References <mailman.979847065.10000.python-list@python.org> <6e96c4c4-17db-464b-b291-816c534b70c4@googlegroups.com> <lm53fo$jhr$1@speranza.aioe.org> <5386a7e2$0$11109$c3e8da3@news.astraweb.com> <lm855p$1mu$1@speranza.aioe.org> <5387d1c4$0$29978$c3e8da3$5496439d@news.astraweb.com> <mailman.10466.1401410797.18130.python-list@python.org> <5387e3b1$0$29978$c3e8da3$5496439d@news.astraweb.com> <mailman.10469.1401415475.18130.python-list@python.org> <5388233e$0$29978$c3e8da3$5496439d@news.astraweb.com> <mailman.10477.1401434346.18130.python-list@python.org> <53886b1e$0$29978$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmoDxRELFWEFH7-XRCQ5N=zkerLKn_s9d1bYj8v7wYhKNg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-71-175-90-87.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
In-Reply-To <CAPTjJmoDxRELFWEFH7-XRCQ5N=zkerLKn_s9d1bYj8v7wYhKNg@mail.gmail.com>
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.10486.1401463473.18130.python-list@python.org> (permalink)
Lines 54
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1401463473 news.xs4all.nl 2829 [2001:888:2000:d::a6]:52711
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:72302

Show key headers only | View raw


On 5/30/2014 7:46 AM, Chris Angelico wrote:

> 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.

Of course it is. A real SyntaxError cannot be caught immediately.* When 
new syntax features are added, breaking the raising of a SyntaxError is 
*not* a consideration. On the other hand, we do not freely change 
AbcError to XyzError even when the latter would be more 'correct'.

* IE, you cannot type

 >>> try: ..
     except SyntaxError: print('caught')

because the SyntaxError during parsing rather than during execution.

> 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",

It does not change what is calculated. It adds introspection output as a 
convenience. The minus is that one may forget that it *is* an addition 
and use the shortcut when writing a script. (I know I have, occasionally.)

 > and what's more, it's making None into a special case:

Which it is, as the 'zero' of the set of Python objects.

>>>> 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.

I disagree.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: How to run script from interpreter? onlyvinish@gmail.com - 2014-05-28 00:44 -0700
  Re: How to run script from interpreter? Terry Reedy <tjreedy@udel.edu> - 2014-05-28 11:32 -0400
  Re: How to run script from interpreter? Mark H Harris <harrismh777@gmail.com> - 2014-05-28 11:39 -0500
    Re: How to run script from interpreter? Steven D'Aprano <steve@pearwood.info> - 2014-05-29 03:22 +0000
      Re: How to run script from interpreter? Mark H Harris <harrismh777@gmail.com> - 2014-05-29 15:26 -0500
        Re: How to run script from interpreter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-30 00:33 +0000
          Re: How to run script from interpreter? Chris Angelico <rosuav@gmail.com> - 2014-05-30 10:46 +1000
            Re: How to run script from interpreter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-30 01:49 +0000
              Re: How to run script from interpreter? Chris Angelico <rosuav@gmail.com> - 2014-05-30 12:04 +1000
                Re: How to run script from interpreter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-30 06:20 +0000
                Re: How to run script from interpreter? Chris Angelico <rosuav@gmail.com> - 2014-05-30 17:19 +1000
                Re: How to run script from interpreter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-30 11:27 +0000
                Re: How to run script from interpreter? Chris Angelico <rosuav@gmail.com> - 2014-05-30 21:46 +1000
                Re: How to run script from interpreter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-30 19:28 +0000
                Re: How to run script from interpreter? Chris Angelico <rosuav@gmail.com> - 2014-05-31 05:47 +1000
                Re: How to run script from interpreter? Terry Reedy <tjreedy@udel.edu> - 2014-05-30 11:24 -0400

csiph-web