Tcl Equivalents of Python Modules

Tcl Equivalents of Python Modules, a resource for Python programmers who have seen the light and are migrating Tcl, maps Python modules to equivalent Tcl packages. APN A cautionary note - the Tcl column is empty not because the functionality is unavailable, but because no one finds it worthwhile to complete the table!

DKF Also note that some of these modules make no sense for Tcl.

The Python Standard Library

Python ModulePython CodeTcl PackageTcl CodeNotes
Built-in Types
Truth Value Testing
Boolean Operations
Comparisons
Numeric Types
Iterator Types
Sequence Typeslist, etc.
Text Sequence Typesstring, etc.Direct feature of Tcl
Binary Sequence Typesbinary, etc.Direct feature of Tcl
Set Types
Mapping Typesarray, dictDirect feature of Tcl
Context Manager Types
Other Built-in Types
Special Attributes
Built-in Exceptions
Text Processing Services
stringstring
'good morning'.capitalize()[string totitle] {good morning}
'good morning'.startswith(somevar)string equal -length [string length $somevar] $somevar {good morning}]
reregexp, regsub
difflib
textwrap
upicodeata
stringprep
readline
rlcompleter
Binary Data Services
struct
codecsbinary encode, binary decode, encoding
Data Types
datetimeclock
datetime.date.today()clock format [clock seconds] -format {%Y %m %d}
calendar
collections
collections.abc
heapq
bisect
array
weakrefNot meaningful in Tcl
types
copy
pprint
reprlib
Numeric and Mathematical Modules
numbers
math
cmath
phase(complex(-1.0, 0.0))expr {atan2(0.0 ,-1.0)}
decimal
fractions
random
seed(100)expr {srand(100)}also returns the first random number
Functional Programming Modules
itertools
functools
operator
File and Directory Access
os.pathfile
fileinput
statfile stat, file lstat
filecmp
tempfile
globglob.glob('./[0-9].*')globglob {./[0-9].*}
fnmatch
linecache
shutil
macpath
Data Persistence
pickle
copyreg
shelve
marshal
dbm
sqlite3sqlite (built-in from 8.6)
Data Compression and Archiving
zlibzlib command, 8.6
gzip
bz2
lzma
zipfile
tarfileTcllib tar
File Formats
csvcsvTcllib
configparser
netrc
xdrlib
plistlib
Cryptographic Services
hashlib
hmac
Generic Operating System Services
os
walkfileutil::traverse
io
time
argparse
optparse
getopt
logging
logging.config
logging.handlers
getpass
curses
curses.textpad
curses.ascii
curses.panel
platform
errno
ctypes
Concurrent Execution
threadingthread
multiprocessing
The concurrent package
concurrent.futures
subprocess
sched
queue
selectfileevent, afterTcl has built-in support for this, but in a way that is more portable to other operating systems and underlying OS APIs
dummy_thread
_thread
_dummy_thread
Interprocess Communication and Networking
socketsocketTcl only has built-in support for TCP sockets; UDP available via packages
ssl
asyncoreTcl has built-in support for async I/O
asynchat
signal
mmap
Internet Data Handling
email
jsonrl_json
mailcap
mailbox
mimetypes
base64binary encode base64, binary decode base64See base64 page on this Wiki for discussion on Tcl older than 8.6
binhex
binascii
quopri
uu
Structured Markup Processing Tools
html
html.parser
html.entities
XML Processing Modules
XML Vulnerabilites
xml.etree.ElementTree
xml.domtDOM
xml.dom.minidom
xml.dom.pulldom
xml.sax
xml.sax.handler
xml.sax.saxutils
xml.sax.xmlreader
xml.parsers.expat
Internet Protocols and Support
webbrowser
cgi
cgitb
wsgiref
urllib
urllib.request
urllib.response
urllib.parse
urllib.error
urllib.rebotparser
httphttp
http.client
ftplib
poplib
imaplib
nntplib
smtplib
smtpd
telnetlib
uuid
socketserver
http.server
http.cookies
http.cookie jar
xmlrpc
xmlrpc.client
xmlrpc.server
ipaddress
Multimedia Services
audioop
aifc
sunau
wave
chunk
colorsys
imghdr
sndhdr
ossaudiodev
Internationalization
gettextmsgcat
locale
Program Frameworks
turtle
cmd
shlex
Graphical User Interfaces with Tk
tkintertk
tkinter.ttkttk
tkinter.tixtix
tkinter.scrolledtext
IDLE
Other Graphical User Interface Packages
Development Tools
pydoc
doctest
unittest
unittest.mock
unittest.mock
2to3
test
test.support
venv
Debugging and Profiling
bdb
faulthandler
pdb
the Python Debugger
timeittime
trace
Python Runtime Services
sys
sysconfig
builtins
_main_
warnings
contestlib
abc
atexit
traceback
_future_
gc
inspect
site
fpectl
distutils
Custom Python Interpreters
code
codeop
Importing Modules
imp
zipimport
pkgutil
modulefinder
runpy
importlib
Python Language Services
parser
ast
symtable
symbol
token
keyword
tokenize
tabnanny
pyclbr
py_compile
compileall
dis
pickletools
Miscellaneous Services
formatter
MS Windows Specific Services
msilib
msvcrt
winregregistry
winsound
Unix Specific Services
posix
pwd
spwd
grp
crypt
termios
tty
ptyTcl programmers would usually use expect instead of this; API very different
fcntl
pipes
resource
nis
syslog