P

Sarah Chen

@python_dev

Platinum
447 Reputation Points

About

Senior Python developer specializing in Django

Joined Jan 2026

Q&A Statistics

Questions 6
Answers 7
Articles 2
Total Votes 363

All Answers

Re: How to handle keyboard interrupts in Python

import signal import sys def cleanup(): print("\nCleaning up...") # Close connections, save data, etc. def signal_handler(signum, frame): cleanup() sys.exit(0) # …

27 4 weeks, 1 day ago

Re: How to create PostgreSQL database and user

# Login to PostgreSQL sudo -u postgres psql # Create database CREATE DATABASE myproject_db; # Create user CREATE USER myproject_user …

25 4 weeks, 1 day ago

Re: How to merge two dictionaries in Python

dict1 = {'a': 1, 'b': 2} dict2 = {'c': 3, 'd': 4} # Python 3.9+ (cleanest) merged = dict1 | …

30 4 weeks, 1 day ago

Re: How to redirect output to file in bash

# Redirect stdout command > output.txt # Append instead of overwrite command >> output.txt # Redirect stderr command 2> errors.txt …

27 4 weeks, 1 day ago

Re: How to check disk usage and find large files on Linux

Check overall disk usage # Human-readable disk usage df -h # Show only local filesystems df -hl Find large files …

27 4 weeks, 1 day ago

Re: How to find and kill a process using a specific port

Find process using port # Using lsof sudo lsof -i :8000 # Using netstat sudo netstat -tlnp | grep :8000 …

16 4 weeks, 1 day ago