<vent> I see there has been traffic over the years on this gripe, so just
let me vent my frustration, and add another reason why 'exit' (or possibly
exit() or quit() or halt() or some such) should exit Python, rather than
giving the ridiculous msg
Use Ctrl-D (i.e. EOF) to exit.
The additional reason is that God intended Ctrl-D to be "scroll down", as in
vi. I have my keyboard translator set up to do something very much like
that (actually, I translate ^D into a sequence of "cursor downs"), and
hitting the Ctrl-D key therefore does not drop me out of Python. More
generally, it is probably not uncommon for someone to translate ^D into
something else, using xmodmap or some such. I need to kill the entire
X-terminal to stop Python.
Now, if you're using a gui Python, there's probably a menu command you can
use to drop out. But if you're using the command-line version (e.g. the one
in CygWin) from a shell prompt, then you're out of luck.
Why isn't there a command or function to drop out of Python??!! Obviously
Python is clever enough to know that you want to exit when you type 'exit';
why does it make you stand on your head to do so?
Aaargh!
</vent>
Mike Maxwell 8 12178
Mike Maxwell wrote: <vent> I see there has been traffic over the years on this gripe, so just let me vent my frustration, and add another reason why 'exit' (or possibly exit() or quit() or halt() or some such) should exit Python, rather than giving the ridiculous msg
Use Ctrl-D (i.e. EOF) to exit.
The additional reason is that God intended Ctrl-D to be "scroll down", as in vi.
Interesting... so God didn't write the ASCII standard, obviously:
ctrl-D 4 EOT END OF TRANSMISSION
A transmission control character used to indicate the conclusion of the transmission of one or more texts..
(From http://www.cs.tut.fi/~jkorpela/chars/c0.html, for example.)
Why anyone would think that ought to be translated as "down" rather than
"I'm done, bye" is unclear to me.
-Peter
Mike Maxwell wrote: that (actually, I translate ^D into a sequence of "cursor downs"), and hitting the Ctrl-D key therefore does not drop me out of Python. More generally, it is probably not uncommon for someone to translate ^D into something else, using xmodmap or some such. I need to kill the entire X-terminal to stop Python.
How the hell do you send a EOF then, to the many other applications that
read from stdin until EOF? (such as most standard unix tools)
(Also see Peter's reply.)
--Irmen
On Mon, 23 Feb 2004 15:12:59 -0500, "Mike Maxwell"
<ma*****@ldc.up enn.edu> wrote: The additional reason is that God intended Ctrl-D to be "scroll down", as in vi.
Sorry God had decided that Ctrl-D was EOF long before vi was even
a bit pattern in Bill Joy's eye.
And of course if you are on the spawn of Satan, EOF is CTRL-Z and
thats how you exit Python...
use to drop out. But if you're using the command-line version (e.g. the one in CygWin) from a shell prompt, then you're out of luck.
raise SystemExit
A wee bit longwinded I'll grant you, but it does the trick...
Alan G.
Author of the Learn to Program website http://www.freenetpages.co.uk/hp/alan.gauld
"Mike Maxwell" <ma*****@ldc.up enn.edu> writes: Why isn't there a command or function to drop out of Python??!!
from sys import exit
exit()
--
Mark Jackson - http://www.alumni.caltech.edu/~mjackson
The *world* is arbitrary. *Individuals* are either fair
or unfair. Which are you? - Caulfield (Jef Mallett)
"Mike Maxwell" <ma*****@ldc.up enn.edu> writes: <vent> I see there has been traffic over the years on this gripe, so just let me vent my frustration, and add another reason why 'exit' (or possibly exit() or quit() or halt() or some such) should exit Python, rather than giving the ridiculous msg
Use Ctrl-D (i.e. EOF) to exit.
of course typing EOF is the normal way to tell any unix stdio app to
exit. but the EOF key depends on your tty settings and is set with
stty. hardcoding ctrl-d is strictly speaking broken ;)
-- erno
[Mark Jackson] "Mike Maxwell" <ma*****@ldc.up enn.edu> writes:
Why isn't there a command or function to drop out of Python??!!
from sys import exit exit()
Or maybe, a bit simpler:
raise SystemExit
One may also manage to merely fall to the end of your __main__ module.
--
François Pinard http://www.iro.umontreal.ca/~pinard
Peter Hansen wrote: ctrl-D 4 EOT END OF TRANSMISSION A transmission control character used to indicate the conclusion of the transmission of one or more texts..
Why anyone would think that ought to be translated as "down" rather than "I'm done, bye" is unclear to me.
To this and other comments along this line, I'll just add my own (not trying
to start a flame war, just explaining what may seem an odd choice on my
part):
IMHO, there's an unfortunate juxtaposition (I won't say confusion) of two
meanings of Ctrl-D: one is the ASCII char (as above), the other is whatever
is produced by pressing the 'd' key while the key labeled 'Ctrl' is pressed.
On Lisp Machines (and if you're too young to know what those were, you're
too young), there was a whole set of special purpose keys, including a Meta
key and a Hyper key. Their effect was similar to the Ctrl or Shift keys, in
that they modified the output of an "ordinary" key. Most keyboards nowadays
come with an Alt key, which could be used for what I want (move the cursor
down 7 rows, or scroll half a screen, or whatever), except that it has a
different function. And since there is no Meta or Hyper key on my keyboard,
I use the key to the left of the 'A' key (easy to reach both that and all
the alphabetic keys at the same time) as a key modifier, to do cursor
movement (^A = beginning of line, ^H = left one char, etc.). It happens
that that modifier key is labeled "Caps Lock" on most modern keyboards.
Under Linux, I can re-map it to a special modifier key, which does not then
interfere with using the Ctrl key to produce the Ascii control chars, so I
can use ^D to kill Python. But it's not so easy to re-map it under Windows,
and the only alternative seems to be to re-map it to be the Ctrl key. (And
don't say that I should just use Linux--the range of standardized cursor
movement keystrokes is _far_ greater under Windows than it is under Linux
environments that I've seen.)
So the upshot of it is, I want to have a keystroke to move down a half dozen
lines _much_ more often than I want one to exit a program. And my fingers
know Ctrl-d.
I might also point out that one can use other modifiers at the same time as
the Ctrl, e.g. Ctrl-Shift-D on my keyboard selects text for seven lines
down. There is obviously no Ascii equivalent of this, but it's a useful
keystroke.
Peter Hansen also wrote: Interesting... so God didn't write the ASCII standard, obviously
No, He used Hebrew. Duh. (I might also point out that the Hebrew alphabet,
lacking a case distinction, would fit nicely into a 6-bit encoding, as was
used on the CDC Cyber 170 that I wrote my dissertation on. You don't know
what a Cyber 170 is? You _are_ too young!)
Mike McSwell
* Erno Kuusela <er*******@erno .iki.fi> [2004-02-23 17:38]: of course typing EOF is the normal way to tell any unix stdio app to exit. but the EOF key depends on your tty settings and is set with stty. hardcoding ctrl-d is strictly speaking broken ;)
I'm not sure if you were implying that python does this...
I just tested it, and it's not hardcoded (2.3a2 darwin).
lap:john$ stty eof ^A
lap:john$ cat
nthoeu
nthoeu
< exited by typing ^A >
lap:john$ python
Python 2.3a2+ (#4, Mar 2 2003, 17:13:46)
[GCC 3.1 20020420 (prerelease)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
< exited by typing ^A >
lap:john$
So, another solution to the OP's problem is to change the EOF character
to something else.
-John
< my_first_name AT my_last_name DOT net > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Baz |
last post by:
Hi All,
I have a problem with the above command. I have a file which is
approximately 7000 lines long. I want to parse that file, extract any
lines containing a certain string, and add that line to a listbox. My
code is roughly as follows:
While Not EOF(1)
Line Input #1, sTemp
|
by: drose0927 |
last post by:
Please help! I can't get my program to exit if the user hits the
Escape button:
When I tried exit(EXIT_SUCCESS), it wouldn't compile and gave me this
error:
Parse Error, expecting `'}''
'else if (choice == 27) exit(0) } }'
Here is my program (Simple loop to display currency equivalencies based
|
by: TTroy |
last post by:
Hello C programmers,
Can someone tell me why ungetc can't sent back EOF, but it's sister
function getc has no trouble sending it to us? For a file, this might
not make a difference, but for an interactive terminal, it is probably
nice to push EOF back (because to user doesn't want to provide an EOF
twice).
How is it getc can send EOF down it's pipe, but we can't send EOF down
ungetc's pipe (especially when this pipe is the same)? ...
|
by: Atanas Banov |
last post by:
i ran onto this weirdness today: seems like close() on popen-ed
(pseudo)file fails miserably with exception instead of returning exit
code, when said exit code is -1.
here is the simplest example (under Windows):
>>> print popen('exit 1').close()
1
>>> print popen('exit -1').close()
Traceback (most recent call last):
|
by: Kaur |
last post by:
Hi,
I need help on a code that each time I add a new record it gives me an
error "Eithe EOF or BOF is true, or the current record has been
deleted. Requested operation requires a current record.
I have an unboud form that records all the objectives. User can put
more than one progress assessment code and comment for each objective.
I have a control on Objective form that opens up Progress assessment
form. The code behind this control...
| |
by: Camellia |
last post by:
Hi all,
Can anyone please tell me how to pass an EOF signal in Eclipse? I've
googled it and searched the CDT manual but still couldn't find it. I've
tried ctrl+c and ctrl+d, they don't work.
Any suggestions are appreciated:)
|
by: ultraclassic |
last post by:
Part of the coding is listed below but when i run this it comes back with EOF and BOF error (Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record)
Error occurs on the line override = rsc("override") am new to programing and not sure where i would need to fix this error or what i would have to do.
The person we had do this is no longer working with us and the...
|
by: ruvi |
last post by:
I am getting runtime error 3021 - Either EOF or BOF is true or the current record has been deleted.....
I have 2 combo boxes in a form- One for the client and the other for the project.
When the form loads, the client combo box gets populated with all the clients.
When a particular client is clicked, the project combo box gets populated with all the projects corresponding to that client.
So far, so good. Now when I click a project in the...
|
by: accessvbanewbie |
last post by:
I keep getting an error stating OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET.
This error just recently began to happen.
I am exporting some records to excel into a preformatted report.
The records are exported successfully but this error pops up before the export is completed.
When I run the debugger this line gives the error message(OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET)
If Not (rsSchedules.EOF = True) Then
Below is my...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |