https://github.com/thunderpoot/dontpanic
A very simple Python module to suppress `KeyboardInterrupt` traceback spam when pressing `^C`.
https://github.com/thunderpoot/dontpanic
douglas-adams python shell utility
Last synced: 24 days ago
JSON representation
A very simple Python module to suppress `KeyboardInterrupt` traceback spam when pressing `^C`.
- Host: GitHub
- URL: https://github.com/thunderpoot/dontpanic
- Owner: thunderpoot
- License: mit
- Created: 2025-02-28T17:02:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-28T19:37:21.000Z (over 1 year ago)
- Last Synced: 2025-09-27T19:26:32.697Z (9 months ago)
- Topics: douglas-adams, python, shell, utility
- Language: Python
- Homepage: https://pypi.org/project/dontpanic/0.1.0/
- Size: 3.91 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🚀 dontpanic
A very simple Python module to suppress `KeyboardInterrupt` traceback spam when pressing `^C`.
## Why?
By default, Python screams at you when you press `^C` to interrupt a script. (Proper languages like [Perl](https://www.perl.org/) don't do this.)
This module catches `KeyboardInterrupt` signals and handles them gracefully.
### Installation
```
pip install dontpanic
```
### Usage
```python
import dontpanic
print('Press control-C to interrupt this program')
while True:
pass # Press ^C to interrupt
```
... or with a custom message:
```python
import dontpanic
dontpanic.set_message("Exiting...")
print('Press control-C to interrupt this program')
while True:
pass # Press ^C to interrupt
```
