473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to stop python...

hi...

perl has the concept of "die". does python have anything similar. how can a
python app be stopped?

the docs refer to a sys.stop.. but i can't find anything else... am i
missing something...

thanks

-bruce

Jul 3 '06 #1
6 4111
bruce <be*******@earthlink.netwrote:
hi...

perl has the concept of "die". does python have anything similar. how can a
python app be stopped?

the docs refer to a sys.stop.. but i can't find anything else... am i
missing something...
import sys

sys.exit()
Alex
Jul 3 '06 #2
bruce wrote:
hi...

perl has the concept of "die". does python have anything similar. how can a
python app be stopped?

the docs refer to a sys.stop.. but i can't find anything else... am i
missing something...

thanks

-bruce
What you want is sys.exit()
See: http://docs.python.org/lib/module-sys.html

Jul 3 '06 #3
"bruce" <be*******@earthlink.netwrote in message
news:ma***************************************@pyt hon.org...
hi...

perl has the concept of "die". does python have anything similar. how can
a
python app be stopped?

the docs refer to a sys.stop.. but i can't find anything else... am i
missing something...

thanks

-bruce
(From the interactive Python prompt:)

import sys
dir(sys)
['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__',
'__st
din__', '__stdout__', '_getframe', 'api_version', 'argv',
'builtin_module_names'
, 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook',
'dllhand
le', 'exc_clear', 'exc_info', 'exc_type', 'excepthook', 'exec_prefix',
'executab
le', 'exit', 'getcheckinterval', 'getdefaultencoding',
'getfilesystemencoding',
'getrecursionlimit', 'getrefcount', 'getwindowsversion', 'hexversion',
'maxint',
'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks',
'path_importer_cach
e', 'platform', 'prefix', 'ps1', 'ps2', 'setcheckinterval', 'setprofile',
'setre
cursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', 'version',
'version_info
', 'warnoptions', 'winver']

(Hmmm, no mention of "stop", but perhaps "exit"???)

help(sys.exit)

Help on built-in function exit in module sys:

exit(...)
exit([status])

Exit the interpreter by raising SystemExit(status).
If the status is omitted or None, it defaults to zero (i.e., success).
If the status is numeric, it will be used as the system exit status.
If it is another kind of object, it will be printed and the system
exit status will be one (i.e., failure).
sys.exit()

Voila!

and now this from the "What's new in Python 2.5":
---------------------------
In the interactive interpreter, quit and exit have long been strings so that
new users get a somewhat helpful message when they try to quit:
>>quit
'Use Ctrl-D (i.e. EOF) to exit.'
In Python 2.5, quit and exit are now objects that still produce string
representations of themselves, but are also callable. Newbies who try quit()
or exit() will now exit the interpreter as they expect. (Implemented by
Georg Brandl.)

---------------------------

So from the ">>>" Python prompt, instead of ^D to exit, one can type quit()
or exit(). Or if sys has been imported, sys.exit(). From within a script,
one can call sys.exit().

-- Paul


Jul 3 '06 #4
On 3/07/2006 2:27 PM, bruce wrote:
hi...

perl has the concept of "die".
does python have anything similar. how can a
python app be stopped?

the docs refer to a sys.stop.. but i can't find anything else... am i
missing something...
Inter alia, sys.exit() and a functional Shift key.
Jul 3 '06 #5
Wow, so many people with the same solution... where's the creativity
folks?

Whenever sys.exit() doesn't work for me, I find that a good solid thump
on the side of the computer case with a large mallet tends to do the
job. And there's always threatening the computer with a degaussing gun!

Jul 3 '06 #6
"cm************@yaho.com" <co**********@gmail.comwrites:
Wow, so many people with the same solution... where's the creativity
folks?

Whenever sys.exit() doesn't work for me, I find that a good solid thump
on the side of the computer case with a large mallet tends to do the
job. And there's always threatening the computer with a degaussing gun!
http://sourceforge.net/tracker/?func...&group_id=5470
Jul 3 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Heikki Salo | last post by:
I have decided to embedd Python into my C++ application and I have one question about it. Everything works perfectly, but I haven´t figured any way to stop the interpreter when it is executing...
2
by: engsol | last post by:
I'm using Python to parse a bunch of s/w test files and make csv files for later report generation by MS ACCESS....(my boss loves the quick turn-around compared to C). Each log file may contain one...
10
by: Xah Lee | last post by:
i'm using groups-beta.google.com to post python code. Is there a way to stop google from messing with my format? it seems to have eaten the spaces in my python code. thanks. Xah...
13
by: python | last post by:
hello and thanks for reading this, i have been a dos/windows user using some form of the basic language for 30 years now. i own and run a small programming company and there is one feature that...
51
by: Hans | last post by:
Hi all, Is there a way that the program that created and started a thread also stops it. (My usage is a time-out). E.g. thread = threading.Thread(target=Loop.testLoop) thread.start() ...
3
by: Saizan | last post by:
I embedded an Rpyc threaded server in a preexistent daemon (an irc bot), this is actually very simple; start_threaded_server(port = DEFAULT_PORT) then I had the necessity to stop the thread which...
0
by: Dirk Runge | last post by:
Hi! I have embedded Python in an C++ App. The Python-Interpreter is running in its own Thread (I'm using PThreads). I use PyRun_SimpleString to run Python-Code that the user entered in an...
6
by: John (Z R) L | last post by:
Hi all, I am very new to programming, and I chose to study the Python language before C++. I am currently using the Wikibooks "Non-Programmer's Tutorial for Python", and am up to the section "Who...
6
by: Alan Isaac | last post by:
I'm fairly new to Python and I've lately been running a script at the interpreter while working on it. Sometimes I only want to run the first quarter or half etc. What is the "good" way to do...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.