Skip to content
_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN DE
Let's talk

Python: 25 One-Liners for Productivity

17. 05. 2022 Updated: 27. 03. 2026 1 min read intermediate
This article was published in 2022. Some information may be outdated.

Python: 25 One-Liners for Productivity

Python is the programmer’s Swiss army knife. Here are 25 one-liners for everyday work.

HTTP and Network

python3 -m http.server 8080 python3 -c “import socket; print(socket.gethostbyname(socket.gethostname()))”

JSON

echo ‘{“a”:1}’ | python3 -m json.tool python3 -c “import csv,json,sys; print(json.dumps(list(csv.DictReader(sys.stdin))))” < data.csv

Generators

python3 -c “import uuid; print(uuid.uuid4())” python3 -c “import secrets,string; print(‘’.join(secrets.choice(string.ascii_letters+string.digits) for _ in range(32)))”

Files

python3 -c “import os; print(sum(os.path.getsize(os.path.join(d,f)) for d,_,files in os.walk(‘.’) for f in files)/1024**2, ‘MB’)”

Cryptography

python3 -c “import hashlib,sys; print(hashlib.sha256(sys.stdin.buffer.read()).hexdigest())”

Date and Time

python3 -c “from datetime import datetime; print(datetime.fromtimestamp(1707900000))” python3 -c “import time; print(int(time.time()))”

Web

python3 -c “from urllib.parse import quote; print(quote(‘hello world’))”

Base64

python3 -c “import base64,sys; print(base64.b64encode(sys.stdin.buffer.read()).decode())”

Math

python3 -c “import math; print(math.factorial(20))” python3 -c “a,b=0,1;exec(‘print(a);a,b=b,a+b;’*20)”

Tip

Save your most-used one-liners as shell aliases. Python is always available.

pythonprogramováníproduktivita
Share:

CORE SYSTEMS team

We build core systems and AI agents that keep operations running. 15 years of experience with enterprise IT.