Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72271
| References | (3 earlier) <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> |
|---|---|
| Date | 2014-05-30 12:04 +1000 |
| Subject | Re: How to run script from interpreter? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10469.1401415475.18130.python-list@python.org> (permalink) |
On Fri, May 30, 2014 at 11:49 AM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > On Fri, 30 May 2014 10:46:34 +1000, Chris Angelico wrote: > >> On Fri, May 30, 2014 at 10:33 AM, Steven D'Aprano >> <steve+comp.lang.python@pearwood.info> wrote: >>> (By the way, ; won't work for a Python shell, because ;spam already is >>> valid Python syntax: it's an empty statement followed by the statement >>> spam, separated by a semicolon.) >> >> That's not really a problem, though. It's not going to stop you from >> doing something actually *useful*, and the fact that the semicolon could >> be syntactically valid isn't going to come into it, because the REPL >> would swallow it anyway. > > The point is that *syntactically valid* Python statements should not > behave differently when running inside the shell or not. I thought > that ;statement was syntactically valid -- but I was wrong. The vanilla > CPython interactive interpreter gives a syntax error, as do IronPython > and Jython. Huh. I responded to your post on the unchecked assumption that ";spam" was syntactically valid. I'm still of the opinion that technically valid (but not useful) constructs are allowed to be swallowed by an interactive interpreter; for instance, it's perfectly valid to write this: >>> x = (1 . imag) But quite a few interpreters (though not Python) take a dot on its own line to mean "flush the buffer, cancel my current command". I couldn't find a way to do this in Python, but if someone proposed adding it, the fact that the above is syntactically legal shouldn't be a proposal blocker. It's on par with creating a file with a name beginning with a hyphen, and then fiddling around with various commands as you try to manipulate it (tip: "rm ./-r" works); programs will happily interpret "-r" as an option rather than a file name, without being concerned that it's technically legal. 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