Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78507 > unrolled thread
| Started by | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| First post | 2014-09-30 17:15 -0400 |
| Last post | 2014-10-01 13:52 -0400 |
| Articles | 13 — 9 participants |
Back to article view | Back to comp.lang.python
Restarting Python Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-30 17:15 -0400
Re: Restarting Python Grant Edwards <invalid@invalid.invalid> - 2014-09-30 21:27 +0000
Re: Restarting Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-10-01 00:24 +0100
Re: Restarting Python Ned Batchelder <ned@nedbatchelder.com> - 2014-09-30 18:05 -0400
Re: Restarting Python Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-30 18:07 -0400
Re: Restarting Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-09-30 22:35 -0400
Re: Restarting Python Terry Reedy <tjreedy@udel.edu> - 2014-09-30 18:58 -0400
Re: Restarting Python Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-30 19:16 -0400
Re: Restarting Python Chris Angelico <rosuav@gmail.com> - 2014-10-01 10:30 +1000
Re: Restarting Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-01 23:08 +1000
Re: Restarting Python Rustom Mody <rustompmody@gmail.com> - 2014-10-01 06:39 -0700
Re: Restarting Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-02 00:47 +1000
Re: Restarting Python Terry Reedy <tjreedy@udel.edu> - 2014-10-01 13:52 -0400
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-09-30 17:15 -0400 |
| Subject | Restarting Python |
| Message-ID | <447m2atpvha8jt21cpulq8qu5p92pmogk3@4ax.com> |
Since the developers of Python decided to make Python 3 non backward compatible, I can't help but wonder why they don't think a command to restart would be a useful addition?
[toc] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-09-30 21:27 +0000 |
| Message-ID | <m0f778$ns3$1@reader1.panix.com> |
| In reply to | #78507 |
On 2014-09-30, Seymore4Head <Seymore4Head@Hotmail.invalid> wrote:
> Since the developers of Python decided to make Python 3 non backward
> compatible, I can't help but wonder why they don't think a command to
> restart would be a useful addition?
Uh... what?
Does that make any sense to anybody else?
--
Grant Edwards grant.b.edwards Yow! My nose feels like a
at bad Ronald Reagan movie ...
gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-10-01 00:24 +0100 |
| Message-ID | <mailman.14501.1412119505.18130.python-list@python.org> |
| In reply to | #78508 |
On 30/09/2014 22:27, Grant Edwards wrote: > On 2014-09-30, Seymore4Head <Seymore4Head@Hotmail.invalid> wrote: > >> Since the developers of Python decided to make Python 3 non backward >> compatible, I can't help but wonder why they don't think a command to >> restart would be a useful addition? > > Uh... what? > > Does that make any sense to anybody else? > Short answer no. Long answer definitely not. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2014-09-30 18:05 -0400 |
| Message-ID | <mailman.14497.1412114737.18130.python-list@python.org> |
| In reply to | #78507 |
On 9/30/14 5:15 PM, Seymore4Head wrote: > Since the developers of Python decided to make Python 3 non backward > compatible, I can't help but wonder why they don't think a command to > restart would be a useful addition? > Starting a process over again in the same way is not something that is easy to do from within the process. How are you running Python? Is it difficult to start it again? -- Ned Batchelder, http://nedbatchelder.com
[toc] | [prev] | [next] | [standalone]
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-09-30 18:07 -0400 |
| Message-ID | <l9am2a9mkpqri66i9ci6slf60qpd60i0b9@4ax.com> |
| In reply to | #78510 |
On Tue, 30 Sep 2014 18:05:20 -0400, Ned Batchelder <ned@nedbatchelder.com> wrote: >On 9/30/14 5:15 PM, Seymore4Head wrote: >> Since the developers of Python decided to make Python 3 non backward >> compatible, I can't help but wonder why they don't think a command to >> restart would be a useful addition? >> > >Starting a process over again in the same way is not something that is >easy to do from within the process. How are you running Python? Is it >difficult to start it again? It is not difficult to start again. It just seems like restart is a missing command. I see many questions asking how to do it.
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2014-09-30 22:35 -0400 |
| Message-ID | <mailman.14504.1412130954.18130.python-list@python.org> |
| In reply to | #78511 |
On Tue, 30 Sep 2014 18:07:32 -0400, Seymore4Head
<Seymore4Head@Hotmail.invalid> declaimed the following:
>On Tue, 30 Sep 2014 18:05:20 -0400, Ned Batchelder
><ned@nedbatchelder.com> wrote:
>
>>On 9/30/14 5:15 PM, Seymore4Head wrote:
>>> Since the developers of Python decided to make Python 3 non backward
>>> compatible, I can't help but wonder why they don't think a command to
>>> restart would be a useful addition?
>>>
>>
>>Starting a process over again in the same way is not something that is
>>easy to do from within the process. How are you running Python? Is it
>>difficult to start it again?
>
>It is not difficult to start again. It just seems like restart is a
>missing command. I see many questions asking how to do it.
Really?
Where?
Your's is the first occurrence I've seen in since I started with Python
(v1.3 or v1.4 -- on an Amiga).
From a command shell? "Restart" is <kill process><up-arrow><return>
Now, if you mean you want to wipe out any stuff defined in an
INTERACTIVE session -- then no... Since interactive sessions are really
just a convenience for testing stuff, and the real program should be a file
that is run from a command line...
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-09-30 18:58 -0400 |
| Message-ID | <mailman.14498.1412117985.18130.python-list@python.org> |
| In reply to | #78507 |
On 9/30/2014 5:15 PM, Seymore4Head wrote: > Since the developers of Python decided to make Python 3 non backward > compatible, This is a trollish exaggeration. > I can't help but wonder why they don't think a command to > restart would be a useful addition? More trollishness. Python does not have 'commands'. Feature additions are independent of the changes make in 3.0. 2.7 got many new features, and even now is getting a few new security features. One cannot have opinions about something they do not think of. If you want to propose a new feature, just do that. Describe a use case and how the feature would look, using current Python syntax, and how it would operate. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-09-30 19:16 -0400 |
| Message-ID | <hbem2apj0h24mnmeu5oqtceagngug6on2t@4ax.com> |
| In reply to | #78512 |
On Tue, 30 Sep 2014 18:58:50 -0400, Terry Reedy <tjreedy@udel.edu> wrote: >On 9/30/2014 5:15 PM, Seymore4Head wrote: >> Since the developers of Python decided to make Python 3 non backward >> compatible, > >This is a trollish exaggeration. > > > I can't help but wonder why they don't think a command to >> restart would be a useful addition? > >More trollishness. Python does not have 'commands'. > >Feature additions are independent of the changes make in 3.0. 2.7 got >many new features, and even now is getting a few new security features. > >One cannot have opinions about something they do not think of. > >If you want to propose a new feature, just do that. Describe a use case >and how the feature would look, using current Python syntax, and how it >would operate. Bad day?
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-10-01 10:30 +1000 |
| Message-ID | <mailman.14503.1412123468.18130.python-list@python.org> |
| In reply to | #78514 |
On Wed, Oct 1, 2014 at 9:16 AM, Seymore4Head <Seymore4Head@hotmail.invalid> wrote: > On Tue, 30 Sep 2014 18:58:50 -0400, Terry Reedy <tjreedy@udel.edu> > wrote: > >>On 9/30/2014 5:15 PM, Seymore4Head wrote: >>> Since the developers of Python decided to make Python 3 non backward >>> compatible, >> >>This is a trollish exaggeration. >> >> > I can't help but wonder why they don't think a command to >>> restart would be a useful addition? >> >>More trollishness. Python does not have 'commands'. >> >>Feature additions are independent of the changes make in 3.0. 2.7 got >>many new features, and even now is getting a few new security features. >> >>One cannot have opinions about something they do not think of. >> >>If you want to propose a new feature, just do that. Describe a use case >>and how the feature would look, using current Python syntax, and how it >>would operate. > > Bad day? No, that's not Terry having a bad day and taking it out on you. That's you making a vague proposal with dubious justification, and Terry coming back to you asking for clarification. As he says, you need to propose new features by saying what they'd do, how they'd do it, and why they should be implemented. Ignore Python's history here, just look at where the language currently is and where you're suggesting it go. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-10-01 23:08 +1000 |
| Message-ID | <542bfce8$0$13009$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #78512 |
Terry Reedy wrote: > Python does not have 'commands'. Terry, even experienced Python developers sometimes describe functions and statements as "commands", e.g. "Use the print command to display results". I think we can cut a beginner like Seymore a bit of slack for misusing terminology. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2014-10-01 06:39 -0700 |
| Message-ID | <187ba983-e98a-4cd0-b19f-d78f6c1bafce@googlegroups.com> |
| In reply to | #78548 |
On Wednesday, October 1, 2014 6:39:11 PM UTC+5:30, Steven D'Aprano wrote: > Terry Reedy wrote: > > Python does not have 'commands'. > Terry, even experienced Python developers sometimes describe functions and > statements as "commands", e.g. "Use the print command to display results". > I think we can cut a beginner like Seymore a bit of slack for misusing > terminology. Agreed in general. However in this case I wonder... Do you even understand what is being requested?
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-10-02 00:47 +1000 |
| Message-ID | <542c13f1$0$13007$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #78507 |
Seymore4Head wrote:
> Since the developers of Python decided to make Python 3 non backward
> compatible, I can't help but wonder why they don't think a command to
> restart would be a useful addition?
Possibly because it isn't a useful addition? Or maybe they just never
thought of it. But more likely the first.
Why doesn't Microsoft Office have a "Restart Office" command? Or Outlook? Or
Notepad? Normally to restart anything, with the exception of the operating
system, you exit/quit, then start again.
Inside the interactive interpreter, I can restart the interpreter with four
keystrokes:
- Ctrl-D
- UP-ARROW
- ENTER
Ctrl-D exits Python and returns me to the shell, UP-ARROW fetches the
previous command ("python"), and ENTER runs that command. On Windows, I
*think* you have to type Ctrl-Z ENTER instead of Ctrl-D, so that will be
five keystrokes. Either way, that's significantly faster and simpler than
using a "restart" function, say:
- type "restart()"
- ENTER
(twelve keystrokes). Even if restarting is a little harder:
- type "quit()"
- press ENTER
- click Start Menu > Programs > Python > Python33.exe
it's still not very hard in the big picture. So having a restart command
would be of very little benefit in the interactive interpreter. (I don't
say *no* benefit.) But it's actually a quite hard thing to do, restarting a
process from within itself. It can obviously be done, since I've seen
programs like Firefox do it, but I'm not sure how to write such a function.
I think that something like this might do the job:
- grab the current process ID;
- start a daemon process which monitors that process ID;
- exit;
- when the daemon process sees that process ID is no longer alive,
start up the application again;
but that glosses over a number of painful difficulties. What if the parent
terminal is no longer running? What about environment variables and command
line arguments? What happens if you are running over a remote shell like
ssh, and the link is terminated as soon as the Python process ends?
So "automatically restart" would be a lot of work, it would quite likely be
fragile and easily broken, and the benefit would be minimal.
But it gets worse... because restart() would also be available when running
non-interactive programs. And it isn't even clear what that should do, let
alone how to do it.
Consider a program like this:
import sys
x = 42
sys.exit()
print("Hello World")
That prints nothing, because exit() stops the program from running any
further. But what if we replace the exit() with a restart()? What would you
expect it to do?
If you expect it to restart, then continue on by printing "Hello World",
then the Python interpreter would have to be completely redesigned from
scratch. All that work, just as a convenience for restarting, is not worth
it.
I note that this sort of system can actually be justified. During the Apollo
program, the landing module's computer was designed to restart when it ran
out of memory and continue on with the current calculation that had been
interrupted:
https://www.hq.nasa.gov/alsj/a11/a11.1201-pa.html
During the eight minutes that it took for the Eagle to land on the moon, the
computer restarted at least five times, including three times in one 40
second period.
http://www.doneyles.com/LM/Tales.html
But Python is a long way from a Lunar Lander, and a restart() command would
be a lot of effort for not much benefit.
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-10-01 13:52 -0400 |
| Message-ID | <mailman.14528.1412186031.18130.python-list@python.org> |
| In reply to | #78551 |
On 10/1/2014 10:47 AM, Steven D'Aprano wrote:
> Inside the interactive interpreter, I can restart the interpreter with four
> keystrokes:
>
> - Ctrl-D
> - UP-ARROW
> - ENTER
>
> Ctrl-D exits Python and returns me to the shell, UP-ARROW fetches the
> previous command ("python"), and ENTER runs that command. On Windows, I
> *think* you have to type Ctrl-Z ENTER instead of Ctrl-D, so that will be
> five keystrokes.
For the console interpreter, this is still true even in 3.5.0a0
>>> ^D
File "<stdin>", line 1
♦
^
SyntaxError: invalid syntax
Idle now quits on ^D on all systems. ^Z (unlike other control chars) is
rejected with an immediate error beep.
Either way, restart is a single click if one have the console or Idle
interpreter icon pinned on the task bar.
Even this is unnecessary with Idle as it has a Restart Shell command on
the Shell menu (hotkey ^F6). (This is automatically invoked when
running an edited file (F5)).
Some problems with restarting are unwinding the call stack, undoing
what has been done, and doing something else so as to not run into the
same problem. We can view every raise -- except pair as a partial
restart of some sort. A minimal startup script something like the
following allows a nearly global restart that addresses all three
problems listed above.
from appmain import main, cleanup, RestartError
restart = False
while True:
try:
main(restart)
except RestartError as err:
cleanup()
restart = err
continue
The main and cleanup functions, switching on the restart arg, and
possibly the class RestartError depend on the app.
--
Terry Jan Reedy
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web