Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72317
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'explicitly': 0.05; '(b)': 0.07; '(python': 0.07; 'expressions': 0.07; 'failing': 0.07; 'interpreter.': 0.07; 'problem?': 0.07; 'suppose': 0.07; 'assigning': 0.09; 'below)': 0.09; 'feature,': 0.09; 'function,': 0.09; 'indeed,': 0.09; 'okay': 0.09; 'prefix': 0.09; 'subject:script': 0.09; 'used.': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'assume': 0.14; '"python': 0.16; "(i'm": 0.16; '(modulo': 0.16; 'argument.': 0.16; 'crosses': 0.16; 'expressions.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'issue),': 0.16; 'it;': 0.16; 'massively': 0.16; 'repl': 0.16; 'script,': 0.16; 'semantics': 0.16; 'subject:run': 0.16; 'tool.': 0.16; 'true:': 0.16; '(you': 0.16; 'sat,': 0.16; ':-)': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'code.': 0.18; 'variable': 0.18; 'value.': 0.19; 'not,': 0.20; 'written': 0.21; '>>>': 0.22; 'code,': 0.22; 'input': 0.22; 'issue.': 0.22; 'putting': 0.22; 'separate': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; '(a)': 0.24; '31,': 0.24; 'closely': 0.24; 'convenient': 0.24; 'script.': 0.24; 'looks': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'define': 0.26; 'mention': 0.26; 'possibly': 0.26; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'feature': 0.29; 'am,': 0.29; 'raise': 0.29; 'said,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; 'that.': 0.31; 'usually': 0.31; 'argue': 0.31; 'commonly': 0.31; 'convenience': 0.31; "d'aprano": 0.31; 'piece': 0.31; 'steven': 0.31; 'interface': 0.32; 'everyone': 0.33; 'not.': 0.33; 'sense': 0.34; "i'd": 0.34; 'subject:from': 0.34; 'could': 0.34; 'problem': 0.35; 'display': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'like,': 0.36; 'var': 0.36; "didn't": 0.36; 'useful': 0.36; 'subject:?': 0.36; 'should': 0.36; 'too': 0.37; 'clear': 0.37; 'being': 0.38; 'desirable': 0.38; 'e.g.': 0.38; 'issue': 0.38; 'that,': 0.38; 'little': 0.38; 'anything': 0.39; 'expect': 0.39; 'supporting': 0.39; 'users': 0.40; 'even': 0.60; 'blank': 0.60; 'commands': 0.60; 'expression': 0.60; 'manually': 0.60; 'break': 0.61; 'mentioned': 0.61; "you're": 0.61; 'further': 0.61; 'first': 0.61; 'such': 0.63; 'decided': 0.64; 'more': 0.64; '(that': 0.65; 'side': 0.67; 'between': 0.67; 'believe': 0.68; 'yes': 0.68; 'legal': 0.71; 'funny': 0.74; 'compose': 0.84; 'confusing': 0.84; 'rexx,': 0.84; 'absolutely': 0.87; '"how': 0.91; 'to:none': 0.92; 'grey': 0.93 |
| 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=TeB9sWHYziLEazZvk1WOJWnUORjQ7TOQzMmSwbrUn/0=; b=QPUtZ9jgU73XeYyuqPOYjg8hZ+5iK9gC9HP+zufF8mQ6I/n2KqX24DLhI3hE3us318 GsxAm6fa3OzhnQr0KwUjKQ8DFOM5VHF8G65VPuRPet3O0PstRrLukTTd8Ok2HPMK3Uz5 OM150Lfw+lTA+6Cvd1ixSSG9Uv8z6uLzGisEZ+zvAcBnaTsg43ikrNvPHbseKGWqvLll 4cpyFDWiMxA5RIjJ2pXMgAbdR3hz63gJqXLWHInDNtAjSmH/fRtbE219jlFMdWIiE07A F8AzeKbVQd2rrZpjHUvYBORO6mfdAH/rUQus7xwq1jPFtvthl6ZL4VXUBvQ0OLrML7gF f2/g== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.147.170 with SMTP id tl10mr13695191vdb.14.1401479265111; Fri, 30 May 2014 12:47:45 -0700 (PDT) |
| In-Reply-To | <5388dbd9$0$29978$c3e8da3$5496439d@news.astraweb.com> |
| 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> <mailman.10483.1401450424.18130.python-list@python.org> <5388dbd9$0$29978$c3e8da3$5496439d@news.astraweb.com> |
| Date | Sat, 31 May 2014 05:47:45 +1000 |
| Subject | Re: How to run script from interpreter? |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <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 <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.10494.1401479273.18130.python-list@python.org> (permalink) |
| Lines | 68 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1401479273 news.xs4all.nl 2895 [2001:888:2000:d::a6]:43846 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:72317 |
Show key headers only | View raw
On Sat, May 31, 2014 at 5:28 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Before you ask, there is no absolutely hard and fast line between "shell
> feature" and "Python code", but the more closely your shell features
> resemble Python code, the harder it will be for users (power or not) to
> keep them separate in their head and the more likely they will be
> confused. E.g. suppose my shell decided to allow lines like
>
> var = len []
>
> to define the variable var and set it to 0. I'd argue that crosses the
> line from "useful convenience feature for power-users" to "dangerously
> confusing misfeature" because it looks too much like Python code. (I'm
> already dubious about len [] on its own.) A better interface is to have a
> clear separation between shell commands and Python, and IPython commonly
> usually uses prefix sigils such as ; % and ! for that.
I think this is the nub of the issue. You believe that anything that's
syntactically legal in a script MUST (a) be syntactically legal, and
(b) have the same semantics (modulo the printing part mentioned below)
in the interactive interpreter. I'm a little less strict, and would be
okay with some things that make little sense being disallowed. There
are already a few such things (you mention the blank line issue), and
the question is more whether they're recommended or not, than whether
they're allowed or not. (Python 3's super() is a piece of magic, and
it's better that it be magical, but it isn't a precedent to be
followed.) I can accept that the desirable line is further over than I
was putting it; practicality is only so-much of an argument.
> You raise the issue of the vanilla Python shell printing the result of
> expressions. That would be the P in REPL, yes? :-) It would be a funny
> REPL that *didn't* print evaluated expressions.
Yes of course, but there's a difference between these:
>>> 1 + 2
3
>>> while True:
input("Echo? ")
if _=="Echo!": break
The first one is using the REPL exactly the way everyone would expect
it to be used. A single expression is entered, and it is printed.
Failing to do that is, indeed, failing on the P of REPL. (That said, a
Read-Eval Loop, sans Print, is still of value. I used one for over a
decade with REXX, manually prefixing things with "say" when I wanted
them printed, err I mean said.) But the second one is looking a lot
more like a script, and if you're writing code like that, you really
should think about assigning the input to a variable and explicitly
printing it, not fiddling with automatic display and the _ capture.
A "top-level expression", if you like, should definitely be printed.
An inner expression isn't so fundamental. Since Python has been
written to print them, we can make use of it; but a REPL that didn't
print inner expressions is still a useful tool. Printing inner
expressions is sliding toward the line of dangerously confusing
misfeatures that you mentioned; you could compose a massively long
function, and deep inside it, call something and have its return value
printed - and then paste that into a script and find that it's not
printing any more. Or, possibly worse, come to python-list with the
question "How do I fix this?", not even knowing what the problem is,
and having us all assume it's a script.
It's a grey area. What's a convenient and useful feature, and what's a
problem? Is supporting "print 1+2" in Python 3 on one side or the
other of that line?
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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