Python

Python is an open-source scripting and general programming language, often used for rapid application development.

Attributes

current versions
contact
g u i d o at C N R I dot R e s t o n dot V A dot U S (Guido van Rossum)
contact
f r e d r i k dot l u n d h at i m a g e dot c o m b i t e c h dot s e (Fredrik Lundh)

See Also

about Python
QuickStudy: Python ,Russel Kay ,2005-05-02
Python Books
IDLE
Tkinter
Python-Tcl-Interactions
Tcl Equivalents of Python Modules
IronPython
an implementation of Python in .NET
news:comp.lang.python
a USENET interface to the Python mailing list
Comparing Tcl with Python
Accessing Tcl and Python from one another
Tcl vs Perl vs Python
Playing Python
AVC — Application View Controller
a multiplatform, fully automatic, live connection among graphical interface widgets and application variables for the Python language.
Cameron Laird's personal notes on Python ,by Cameron Laird
An Introduction to Tkinter (Work in Progress)
last updated in 2005.
Qt and PyQt ,Boudewijn Rempt and David Mertz ,2003-02-11
alternative to Tkinter
BASIC Comuter Use Today ,by Bruce Gingery (b g i n g e r y at g t c s dot c o m
an article that compares Tcl/Tk, Perl/Tk, and Python/Tk to early 1980's BASIC using a simple example
7th International Python Conference ,Trip report (alternative: [L1 ]) , by Frank Stajano
in which Frank coins the the Pytho logo, "batteries included"
Implementing the SMS server, or why I switched from Tcl to Python ,Frank Stajano
"incr Tcl offers a more complete and much-cleaner object-oriented support than Python". Too bad Frank didn't stick around for TclOO! "I prefer Python because its standard library is a gold mine."
The Year In Scripting Languages Lua/Perl/Python/Ruby/Tcl ,Mitchell Charity ,2003-01
an historically-interesting summary of scripting language developments in 2002.
Sidebar: Zope Spurs Python growth ,Russel Kay ,2005-05-02
The popularity of Zope (Z Object Publishing Environment), an open-source Web application server and portal tool kit written in Python, has increased interest in the programming language.
An empirical comparison of C, C++, Java, Perl, Python, Ress, and Tcl, by Lutz Prechelt ,2000-03-10

Tools

critlib's Typcl
an extension to use Tcl *from* Python. It doesn't really require CriTcl and could have been done in standard C.
Elmer
Elmer allows developers to write code in Python and execute it in Tcl. The resulting Tcl interface to the Python code generated by Elmer is transparent to the Tcl user... Python calls appear as Tcl calls ( "foo( 1, "a" )" in Python appears as "foo 1 a" in Tcl, for example) and Python and Tcl data types are automatically mapped (Tcl lists are converted to Python lists, Python dictionaries are returned as Tcl associative arrays, etc.). Elmer also supports Python's "freeze" module, allowing a Python developer to deliver a single library consisting of several Python files "frozen" in to the Tcl application... no need to set PYTHONPATH or have Python source files accompanying the Tcl application.
libtclpy
a Tcl extension to call Python from inside Tcl. The intention is to take the good parts of Elmer and tclpython and combine them to let you get going as fast as possible.

Description

Python includes a standard facility for object-oriented programming.

Tcl is bundled into Python in order to make Tk available as the Python module, Tkinter. Beginning at version v1.5.2, includes IDLE, an integrated development environment for Python that requires Tkinter. Python 2.4 not only supports Tk on Unix, but Tk on Windows and Macintosh platforms as well.

An example of converting a Tcl list to a Python tuple:

#! /bin/env python

import Tkinter
tcl = Tkinter.Tcl()
result = tcl.call('lrange' ,'''one {two and} three''' ,0 ,'end')

To evaluate a Tcl script:

#! /bin/env python

import Tkinter
tcl = Tkinter.Tcl()
result = tcl.eval('some Tcl script here')

ActiveState provides Active Python binary downloads for Linux, Solaris and Windows.

Python, Enthought Edition , now Enthought Canopy , provides Python+packages bundle.

Misc

AMG: Does anyone have Tcl code to read Python pickle [L2 ] data? Tcl pickle, heh. Maybe someday I might develop it, if no one else has already done so.


"a Python script can be expected to work for two to three years, but not for five or more. Older scripts will either crash, which is a nuisance, or produce different results, which is much worse because the problem may well go unnoticed." [L3 ]


The Art of dividing two numbers in Python:

% Python 2.7
>>> 5 / 2
2

% Python 3.x
>>> 5 / 2
2.5

% Python 2.7
>>> from __future__ import division
...
>>> 5 / 2
2.5

% Python 2.7/3.x
>>> 5 // 2
2
>>> 1 / 0.2
5
>>> 1 // 0.2
4

arjen - 2019-08-30 07:43:20

What exactly is the difference between / and // in Python? I could imagine what is going on in the first few examples, but "1//0.2" resulting in "4" really makes me wonder ...


In theory (see PEP 238 ) the operator // realizes a flooring division and a // b could be equivalent to math.floor(a / b). But it seems there are hairy corners behind the scenes and this is not equivalent (Python 3.4.1):

>>> import math
>>> math.floor(1 / 0.2)
5
>>> 1 // 0.2
4
>>> math.floor(44 / 4.4)
10
>>> 44 // 4.4
9.0

However after the division operator was "improved" people seem to have great fun to figure out how division actually behaves for their packages and Python version. Tcl...

% expr 5 / 2
2
% expr 5 / 2.0
2.5
% expr 1 / 0.2
5.0
% expr floor(1 / 0.2)
5.0

another example divison in python


"Any language that can’t process valid filenames has serious bugs – and Python is littered with these bugs."

"At this point, I am extremely unlikely to use Python for any new project due to these issues."

-- The Incredible Disaster of Python 3


"Python is not a great programming language. It's great for beginners. Then it turns into a mess." [L4 ]