Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72293
| References | (7 earlier) <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> |
|---|---|
| Date | 2014-05-30 21:46 +1000 |
| Subject | Re: How to run script from interpreter? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10483.1401450424.18130.python-list@python.org> (permalink) |
On Fri, May 30, 2014 at 9:27 PM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> 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
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