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.
Python Module | Python Code | Tcl Package | Tcl Code | Notes |
---|---|---|---|---|
Built-in Types | ||||
Truth Value Testing | ||||
Boolean Operations | ||||
Comparisons | ||||
Numeric Types | ||||
Iterator Types | ||||
Sequence Types | list, etc. | |||
Text Sequence Types | string, etc. | Direct feature of Tcl | ||
Binary Sequence Types | binary, etc. | Direct feature of Tcl | ||
Set Types | ||||
Mapping Types | array, dict | Direct feature of Tcl | ||
Context Manager Types | ||||
Other Built-in Types | ||||
Special Attributes | ||||
Built-in Exceptions | ||||
Text Processing Services | ||||
string | string | |||
'good morning'.capitalize() | [string totitle] {good morning} | |||
'good morning'.startswith(somevar) | string equal -length [string length $somevar] $somevar {good morning}] | |||
re | regexp, regsub | |||
difflib | ||||
textwrap | ||||
upicodeata | ||||
stringprep | ||||
readline | ||||
rlcompleter | ||||
Binary Data Services | ||||
struct | ||||
codecs | binary encode, binary decode, encoding | |||
Data Types | ||||
datetime | clock | |||
datetime.date.today() | clock format [clock seconds] -format {%Y %m %d} | |||
calendar | ||||
collections | ||||
collections.abc | ||||
heapq | ||||
bisect | ||||
array | ||||
weakref | Not 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.path | file | |||
fileinput | ||||
stat | file stat, file lstat | |||
filecmp | ||||
tempfile | ||||
glob | glob.glob('./[0-9].*') | glob | glob {./[0-9].*} | |
fnmatch | ||||
linecache | ||||
shutil | ||||
macpath | ||||
Data Persistence | ||||
pickle | ||||
copyreg | ||||
shelve | ||||
marshal | ||||
dbm | ||||
sqlite3 | sqlite (built-in from 8.6) | |||
Data Compression and Archiving | ||||
zlib | zlib command, 8.6 | |||
gzip | ||||
bz2 | ||||
lzma | ||||
zipfile | ||||
tarfile | Tcllib tar | |||
File Formats | ||||
csv | csv | Tcllib | ||
configparser | ||||
netrc | ||||
xdrlib | ||||
plistlib | ||||
Cryptographic Services | ||||
hashlib | ||||
hmac | ||||
Generic Operating System Services | ||||
os | ||||
walk | fileutil::traverse | |||
io | ||||
time | ||||
argparse | ||||
optparse | ||||
getopt | ||||
logging | ||||
logging.config | ||||
logging.handlers | ||||
getpass | ||||
curses | ||||
curses.textpad | ||||
curses.ascii | ||||
curses.panel | ||||
platform | ||||
errno | ||||
ctypes | ||||
Concurrent Execution | ||||
threading | thread | |||
multiprocessing | ||||
The concurrent package | ||||
concurrent.futures | ||||
subprocess | ||||
sched | ||||
queue | ||||
select | fileevent, after | Tcl 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 | ||||
socket | socket | Tcl only has built-in support for TCP sockets; UDP available via packages | ||
ssl | ||||
asyncore | Tcl has built-in support for async I/O | |||
asynchat | ||||
signal | ||||
mmap | ||||
Internet Data Handling | ||||
json | rl_json | |||
mailcap | ||||
mailbox | ||||
mimetypes | ||||
base64 | binary encode base64, binary decode base64 | See 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.dom | tDOM | |||
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 | ||||
http | http | |||
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 | ||||
gettext | msgcat | |||
locale | ||||
Program Frameworks | ||||
turtle | ||||
cmd | ||||
shlex | ||||
Graphical User Interfaces with Tk | ||||
tkinter | tk | |||
tkinter.ttk | ttk | |||
tkinter.tix | tix | |||
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 | ||||
timeit | time | |||
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 | ||||
winreg | registry | |||
winsound | ||||
Unix Specific Services | ||||
posix | ||||
pwd | ||||
spwd | ||||
grp | ||||
crypt | ||||
termios | ||||
tty | ||||
pty | Tcl programmers would usually use expect instead of this; API very different | |||
fcntl | ||||
pipes | ||||
resource | ||||
nis | ||||
syslog |