What "tools" are available in the Python standard library

I currently know two tools:

  • base64 encoder / decoder:

    python -m base64 -e <input
    python -m base64 -d <input

  • json validator and beautiful printer

    python -m json.tool <input

where the input can be stdin or a file.

I am curious if there are other open source SPL tools that work the same way?

+43
python
Jan 27 '13 at 6:23
source share
4 answers

A lot of.

 $ grep "if __name__ == '__main__':" /usr/lib64/python2.7/* | wc -l 55 

Not everyone works as a filter, so study this module before starting.

+29
Jan 27 '13 at 6:33
source share

Not a complete list ...

Encoding

Base64 en / decoding:

 python -m base64 -d [file] python -m base64 -e [file] 

ROT-13 ru / decoder:

 python -m encodings.rot_13 

Macintosh BinHex:

 # binhex <file> to <file>.hqx, and unbinhex <file>.hqx to <file>.viahqx python -m binhex <file> 

UUencode / Decoding:

 python -m uu [infile [outfile]] # encode python -m uu -d [infile [outfile]] # decode 

MIME quoted-printable en / decoding:

 python -m mimify -e [infile [outfile]] # encode python -m mimify -d [infile [outfile]] # decode 

Available for encoding / decoding:

 python -m quopri [file] # encode python -m quopri -d [file] # decode 

Compression

Gzip:

 python -m gzip [file] # compress python -m gzip -d [file] # decompress 

extract zipfile etc:

 python -m zipfile -l <file> # list python -m zipfile -t <file> # test python -m zipfile -e <file> <dir> # extract python -m zipfile -c <file> sources... # create 

the Internet

HTTP servers:

 python -m BaseHTTPServer python -m CGIHTTPServer python -m SimpleHTTPServer 

Simple FTP client:

 python -m ftplib host [-l<dir-to-list>] [-d<dir-to-cwd>] [-p] [file-to-retrieve] 

HTML text highlighting:

 python -m htmllib <file> 

JSON Validator and Pretty-Printer:

 python -m json.tool [infile [outfile]] 

List of POP3 Mailboxes:

 python -m poplib <server> <username> <password> 

SMTP server:

 python -m smtpd 

Send email (to localhost):

 python -m smtplib 

Telnet Client:

 python -m telnetlib [host [port]] 

MIME Database / Extension:

 python -m mimetypes file.ext # print type for filename python -m mimetypes -e mime/type # print extension for type 

Open web browser:

 python -m webbrowser -n <url> # new window python -m webbrowser -t <url> # new tab 

Antigravity :

 python -m antigravity 

Python

Pure-Python REPL:

 python -m code 

Python Bytecode Batch Compiler:

 python -m compileall 

Python Code Profiler:

 python -m cProfile <script> python -m profile <script> python -m pstats <filename> # print profiling statistics 

Python Release Artist:

 python -m doctest <script> 

Python test:

 python -m test.pystone [iterations] python -m hotshot.stones 

Python Interactive Debugger:

 python -m pdb 

Extract Python classes and methods from the module:

 python -m pyclbr <script> 

Python documentation browser:

 python -m pydoc <topic> python -m pydoc -g # graphical browser python -m pydoc -p <port> # start HTTP docs server on port 

Python snippet timer:

 python -m timeit 

Miscellaneous

Calendar (e.g. cal , but can do HTML and various fancy formatting):

 python -m calendar 

Directories:

 python -m filecmp [-r] dir1 dir2 # -r for recursive directory compare 

Paragraph formatting:

 python -m formatter [file] 

Show current platform (e.g. uname , but simpler):

 python -m platform 
+106
Jan 27 '13 at 7:27
source share

In addition, there are:

 python -m this 
+12
May 6 '13 at 11:21
source share

There are also compatible packages at Cheeseshop. Try "e" or "oo" :-)

+1
May 6 '13 at 3:39
source share



All Articles