Skip to content

Instantly share code, notes, and snippets.

@damianesteban
Forked from pankajparashar-zz/one-liners.py
Created September 2, 2013 06:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damianesteban/6409845 to your computer and use it in GitHub Desktop.
Save damianesteban/6409845 to your computer and use it in GitHub Desktop.
# Python Help
python -h
# Calendar
python -m calendar
python -m calendar -h
python -m calendar 1999
# Zip and Gzip Tools
python -m zipfile -l pcblib.zip
python -m zipfile -e pcblib.zip
python -m zipfile -c release.zip *.py
python -m gzip -d mydata.tar.gz
# Pretty JSON Printer
python -m json.tool < mydata.json
# Unicode Characters
python -c "import unicodedata; print unicodedata.name(unichr(0x2249))"
python -c "print unichr(0x2249)"
# Web Servers
python -m SimpleHTTPServer
python -m CGIHTTPServer
python -m smtpd -n -c DebuggingServer localhost:8025
# Python Doc
python -m pydoc
python -m pydoc -k
# Python Debugger
python -m pdb
# Interactive profile statistics browser
python -m pstats
# String processing
python -c "import sys; print ''.join(x.capitalize() for x in sys.stdin)" < names.txt
# Numerical processing
python -c "import sys, math; print math.fsum(float(x) for x in sys.stdin)" < numbers.dat
# What is the easiest way to get a URL encoded password?
python -c 'from getpass import getpass; from urllib import quote; print quote(getpass("Proxy Password: "))'
# The Zen of Python
python -m this
python -c "import this"
# xkcd 353
python -c "import antigravity"
# Braces instead of whitespace
python -c "from __future__ import braces"
# A CS lecture
python -c "import heapq; print heapq.__about__"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment