Python 2

Posted : admin On 1/26/2022

At that link it says under Prerequisites 'Install Python 2.7 (v3.x.x is not supported), and run npm config set python python2.7' I don't want to install Python 2 as I have Python 3 and I don't want to mess that up. I am trying to install Node.js so that I can run ESlint and Prettier in Visual Studio Code. As of January 1, 2020, the 2.x branch of the Python programming language is no longer supported by its creators, the Python Software Foundation. Directed by Lee Alan McConnell. With William Zabka, Dana Ashbrook, Alex Jolig, Simmone Mackinnon. A man, his business partner, and his wife are enlisted to transport an unknown object from a Russian military base, only to discover that the object is a giant, genetically-altered python.

Python 2.0

Note: This is no longer the most current Pythonrelease. See Python 2.0.1 for a patch releaseand the download page for more recentreleases.

The final version of Python 2.0 was released on October 16, 2000.

  • What's new (overview)
  • What's new (details)

Post-release news

For critical patches, a Python 2.0 specific FAQ, and other issuesthat have come up since the release, please go to the new Python 2.0 infoarea, a set of user-editable webpages. If you have informationabout Python 2.0 you can discuss it there.

Bugs and Patches

To report a bug, always use the SourceForge Bug Tracker. Ifyou have a patch, please use the SourceForge Patch Manager.


The final version of Python 2.0 is available for download now.

  • Windows installer. To install Python, Windows users need only download the Windowsinstaller and run it.
  • Source code (.tar.gz, 3.9MB) or(.tar.bz2, 3.3MB)
  • Linux RPMs
    PackageSource (gzip)Source (bzip2)Source RPMRedHat 6.1 RPM

Notes for Windows users:

If you're running Windows 95, 98, ME, NT or 2000, all you need isthe Windows installer. It includes Python, Tcl/Tk, and thedocumentation in HTML format. Simply download the installer and runit.

Some browsers remove the '.exe'suffix of the downloaded installer file. If this happens to you,simply rename the downloaded file to 'python20.exe' before youdouble-click it to run the installer. Also, if you have everinstalled an older Python version (especially distributions fromPythonWare), you may have to remove references to it from yourautoexec.bat.

Advanced Windows developers may also wish to download the Win32 extensions, by Mark Hammond of ActiveState. These makemany Microsoft Windows APIs available from Python.

Incompatibility warning: Norton Antivirus 2000 can causeblue screen crashes on Windows 98 when a function in the os.popen*()family is invoked. To prevent this problem, disable Norton Antiviruswhen using Python. (Confirmed on Windows 98 Second Edition withNorton Antivirus version 6.10.20. The same Norton Antivirus versiondoesn't have this problem on Windows 2000. Norton Antivirus version 5on Windows 98SE doesn't have this problem either.)

What's New in Python 2.0?

For a comprehensive discussion of the differences between Python2.0 and Python 1.5.2, please see the article What's New in Python 2.0 by A.M. Kuchlingand Moshe Zadka.

What's new in 2.0 (since release candidate 1)?

Standard library

  • The copy_reg module was modified to clarify its intended use: to register pickle support for extension types, not for classes. pickle() will raise a TypeError if it is passed a class.
  • Fixed a bug in gettext's 'normalize and expand' code that prevented it from finding an existing .mo file.
  • Restored support for HTTP/0.9 servers in httplib.
  • The math module was changed to stop raising OverflowError in case of underflow, and return 0 instead in underflow cases. Whether Python used to raise OverflowError in case of underflow was platform- dependent (it did when the platform math library set errno to ERANGE on underflow).
  • Fixed a bug in StringIO that occurred when the file position was not at the end of the file and write() was called with enough data to extend past the end of the file.
  • Fixed a bug that caused Tkinter error messages to get lost on Windows. The bug was fixed by replacing direct use of interp->result with Tcl_GetStringResult(interp).
  • Fixed bug in urllib2 that caused it to fail when it received an HTTP redirect response.
  • Several changes were made to distutils: Some debugging code was removed from util. Fixed the installer used when an external zip program (like WinZip) is not found; the source code for this installer is in Misc/distutils. check_lib() was modified to behave more like AC_CHECK_LIB by add other_libraries() as a parameter. The test for whether installed modules are on sys.path was changed to use both normcase() and normpath().
  • Several minor bugs were fixed in the xml package (the minidom, pulldom, expatreader, and saxutils modules).
  • The regression test driver ( behavior when invoked with -l changed: It now reports a count of objects that are recognized as garbage but not freed by the garbage collector.
  • The regression test for the math module was changed to test exceptional behavior when the test is run in verbose mode. Python cannot yet guarantee consistent exception behavior across platforms, so the exception part of test_math is run only in verbose mode, and may fail on your platform.


  • PyOS_CheckStack() has been disabled on Win64, where it caused test_sre to fail.

Build issues

  • Changed compiler flags, so that gcc is always invoked with -Wall and -Wstrict-prototypes. Users compiling Python with GCC should see exactly one warning, except if they have passed configure the --with-pydebug flag. The expected warning is for getopt() in Modules/main.c. This warning will be fixed for Python 2.1.
  • Fixed configure to add -threads argument during linking on OSF1.

Tools and other miscellany

  • The compiler in Tools/compiler was updated to support the new language features introduced in 2.0: extended print statement, list comprehensions, and augmented assignments. The new compiler should also be backwards compatible with Python 1.5.2; the compiler will always generate code for the version of the interpreter it runs under.

What's new in 2.0 release candidate 1 (since beta 2)?

What is release candidate 1?

We believe that release candidate 1 will fix all known bugs that weintend to fix for the 2.0 final release. This release should be a bitmore stable than the previous betas. We would like to see even morewidespread testing before the final release, so we are producing thisrelease candidate. The final release will be exactly the same unlessany show-stopping (or brown bag) bugs are found by testers of therelease candidate.

All the changes since the last beta release are bug fixes or changesto support building Python for specific platforms.

Core language, builtins, and interpreter

  • A bug that caused crashes when __coerce__ was used with augmented assignment, e.g. +=, was fixed.
  • Raise ZeroDivisionError when raising zero to a negative number, e.g. 0.0 ** -2.0. Note that math.pow is unrelated to the builtin power operator and the result of math.pow(0.0, -2.0) will vary by platform. On Linux, it raises a ValueError.
  • A bug in Unicode string interpolation was fixed that occasionally caused errors with formats including '%%'. For example, the following expression '%% %s' % u'abc' no longer raises a TypeError.
  • Compilation of deeply nested expressions raises MemoryError instead of SyntaxError, e.g. eval('[' * 50 + ']' * 50).
  • In 2.0b2 on Windows, the interpreter wrote .pyc files in text mode, rendering them useless. They are now written in binary mode again.

Standard library

  • Keyword arguments are now accepted for most pattern and match object methods in SRE, the standard regular expression engine.
  • In SRE, fixed error with negative lookahead and lookbehind that manifested itself as a runtime error in patterns like '(?<!abc)(def)'.
  • Several bugs in the Unicode handling and error handling in _tkinter were fixed.
  • Fix memory management errors in Merge() and Tkapp_Call() routines.
  • Several changes were made to cStringIO to make it compatible with the file-like object interface and with StringIO. If operations are performed on a closed object, an exception is raised. The truncate method now accepts a position argument and readline accepts a size argument.
  • There were many changes made to the linuxaudiodev module and its test suite; as a result, a short, unexpected audio sample should now play when the regression test is run.
Note that this module is named poorly, because it should work correctly on any platform that supports the Open Sound System (OSS). The module now raises exceptions when errors occur instead of crashing. It also defines the AFMT_A_LAW format (logarithmic A-law audio) and defines a getptr() method that calls the SNDCTL_DSP_GETxPTR ioctl defined in the OSS Programmer's Guide.
  • The library_version attribute, introduced in an earlier beta, was removed because it can not be supported with early versions of the C readline library, which provides no way to determine the version at compile-time.
  • The binascii module is now enabled on Win64.
  • no longer suffers 'recursion depth' errors when parsing programs with very long string literals.


  • Fixed several buffer overflow vulnerabilities in calculate_path(), which is called when the interpreter starts up to determine where the standard library is installed. These vulnerabilities affect all previous versions of Python and can be exploited by setting very long values for PYTHONHOME or argv[0]. The risk is greatest for a setuid Python script, although use of the wrapper in Misc/setuid-prog.c will eliminate the vulnerability.
  • Fixed garbage collection bugs in instance creation that were triggered when errors occurred during initialization. The solution, applied in cPickle and in PyInstance_New(), is to call PyObject_GC_Init() after the initialization of the object's container attributes is complete.
  • pyexpat adds definitions of PyModule_AddStringConstant and PyModule_AddObject if the Python version is less than 2.0, which provides compatibility with PyXML on Python 1.5.2.
  • If the platform has a bogus definition for LONG_BIT (the number of bits in a long), an error will be reported at compile time.
  • Fix bugs in _PyTuple_Resize() which caused hard-to-interpret garbage collection crashes and possibly other, unreported crashes.
  • Fixed a memory leak in _PyUnicode_Fini().

Build issues

  • configure now accepts a --with-suffix option that specifies the executable suffix. This is useful for builds on Cygwin and Mac OS X, for example.
  • The mmap.PAGESIZE constant is now initialized using sysconf when possible, which eliminates a dependency on -lucb for Reliant UNIX.
  • The md5 file should now compile on all platforms.
  • The select module now compiles on platforms that do not define POLLRDNORM and related constants.
  • Darwin (Mac OS X): Initial support for static builds on this platform.
  • BeOS: A number of changes were made to the build and installation process. ar-fake now operates on a directory of object files. dl_export.h is gone, and its macros now appear on the mwcc command line during build on PPC BeOS.
  • Platform directory in lib/python2.0 is 'plat-beos5' (or 'plat-beos4', if building on BeOS 4.5), rather than 'plat-beos'.
  • Cygwin: Support for shared libraries, Tkinter, and sockets.
  • SunOS 4.1.4_JL: Fix test for directory existence in configure.

Tools and other miscellany

  • Removed debugging prints from main used with freeze.
  • IDLE auto-indent no longer crashes when it encounters Unicode characters.

What's new in 2.0 beta 2 (since beta 1)?

Core language, builtins, and interpreter

  • Add support for unbounded ints in %d,i,u,x,X,o formats; for example '%d' % 2L**64 '18446744073709551616'.
  • Add -h and -V command line options to print the usage message and Python version number and exit immediately.
  • eval() and exec accept Unicode objects as code parameters.
  • getattr() and setattr() now also accept Unicode objects for the attribute name, which are converted to strings using the default encoding before lookup.
  • Multiplication on string and Unicode now does proper bounds checking; e.g. 'a' * 65536 * 65536 will raise ValueError, 'repeated string is too long.'
  • Better error message when continue is found in try statement in a loop.

Standard library and extensions

  • array: reverse() method of array now works. buffer_info() now does argument checking; it still takes no arguments.
  • asyncore/asynchat: Included most recent version from Sam Rushing.
  • cgi: Accept '&' or ';' as separator characters when parsing form data.
  • CGIHTTPServer: Now works on Windows (and perhaps even Mac).
  • ConfigParser: When reading the file, options spelled in upper case letters are now correctly converted to lowercase.
  • copy: Copy Unicode objects atomically.
  • cPickle: Fail gracefully when copy_reg can't be imported.
  • cStringIO: Implemented readlines() method.
  • dbm: Add get() and setdefault() methods to dbm object. Add constant `library' to module that names the library used. Added doc strings and method names to error messages. Uses configure to determine which ndbm.h file to include; Berkeley DB's nbdm and GDBM's ndbm is now available options.
  • distutils: Update to version 0.9.3.
  • dl: Add several dl.RTLD_ constants.
  • fpectl: Now supported on FreeBSD.
  • gc: Add DEBUG_SAVEALL option. When enabled all garbage objects found by the collector will be saved in gc.garbage. This is useful for debugging a program that creates reference cycles.
  • httplib: Three changes: Restore support for set_debuglevel feature of HTTP class. Do not close socket on zero-length response. Do not crash when server sends invalid content-length header.
  • mailbox: Mailbox class conforms better to qmail specifications.
  • marshal: When reading a short, sign-extend on platforms where shorts are bigger than 16 bits. When reading a long, repair the unportable sign extension that was being done for 64-bit machines. (It assumed that signed right shift sign-extends.)
  • operator: Add contains(), invert(), __invert__() as aliases for __contains__(), inv(), and __inv__() respectively.
  • os: Add support for popen2() and popen3() on all platforms where fork() exists. (popen4() is still in the works.)
  • os: (Windows only:) Add startfile() function that acts like double- clicking on a file in Explorer (or passing the file name to the DOS 'start' command).
  • os.path: (Windows, DOS:) Treat trailing colon correctly in os.path.join. os.path.join('a:', 'b') yields 'a:b'.
  • pickle: Now raises ValueError when an invalid pickle that contains a non-string repr where a string repr was expected. This behavior matches cPickle.
  • posixfile: Remove broken __del__() method.
  • py_compile: support CR+LF line terminators in source file.
  • readline: Does not immediately exit when ^C is hit when readline and threads are configured. Adds definition of rl_library_version. (The latter addition requires GNU readline 2.2 or later.)
  • rfc822: Domain literals returned by AddrlistClass method getdomainliteral() are now properly wrapped in brackets.
  • site: sys.setdefaultencoding() should only be called in case the standard default encoding ('ascii') is changed. This saves quite a few cycles during startup since the first call to setdefaultencoding() will initialize the codec registry and the encodings package.
  • socket: Support for size hint in readlines() method of object returned by makefile().
  • sre: Added experimental expand() method to match objects. Does not use buffer interface on Unicode strings. Does not hang if group id is followed by whitespace.
  • StringIO: Size hint in readlines() is now supported as documented.
  • struct: Check ranges for bytes and shorts.
  • urllib: Improved handling of win32 proxy settings. Fixed quote and quote_plus functions so that the always encode a comma.
  • Tkinter: Image objects are now guaranteed to have unique ids. Set to zero if Tk version doesn't support mousewheel. Removed some debugging prints.
  • UserList: now implements __contains__().
  • webbrowser: On Windows, use os.startfile() instead of os.popen(), which works around a bug in Norton AntiVirus 2000 that leads directly to a Blue Screen freeze.
  • xml: New version detection code allows PyXML to override standard XML package if PyXML version is greater than 0.6.1.
  • xml.dom: DOM level 1 support for basic XML. Includes xml.dom.minidom (conventional DOM), and xml.dom.pulldom, which allows building the DOM tree only for nodes which are sufficiently interesting to a specific application. Does not provide the HTML-specific extensions. Still undocumented.
  • xml.sax: SAX 2 support for Python, including all the handler interfaces needed to process XML 1.0 compliant XML. Some documentation is already available.
  • pyexpat: Renamed to xml.parsers.expat since this is part of the new, packagized XML support.


  • Add three new convenience functions for module initialization -- PyModule_AddObject(), PyModule_AddIntConstant(), and PyModule_AddStringConstant().
  • Cleaned up definition of NULL in C source code; all definitions were removed and add #error to Python.h if NULL isn't defined after #include of stdio.h.
  • Py_PROTO() macros that were removed in 2.0b1 have been restored for backwards compatibility (at the source level) with old extensions.
  • A wrapper API was added for signal() and sigaction(). Instead of either function, always use PyOS_getsig() to get a signal handler and PyOS_setsig() to set one. A new convenience typedef PyOS_sighandler_t is defined for the type of signal handlers.
  • Add PyString_AsStringAndSize() function that provides access to the internal data buffer and size of a string object - or the default encoded version of a Unicode object.
  • PyString_Size() and PyString_AsString() accept Unicode objects.
  • The standard header <limits.h> is now included by Python.h (if it exists). INT_MAX and LONG_MAX will always be defined, even if <limits.h> is not available.
  • PyFloat_FromString takes a second argument, pend, that was effectively useless. It is now officially useless but preserved for backwards compatibility. If the pend argument is not NULL, *pend is set to NULL.
  • PyObject_GetAttr() and PyObject_SetAttr() now accept Unicode objects for the attribute name. See note on getattr() above.
  • A few bug fixes to argument processing for Unicode. PyArg_ParseTupleAndKeywords() now accepts 'es#' and 'es'. PyArg_Parse() special cases 's#' for Unicode objects; it returns a pointer to the default encoded string data instead of to the raw UTF-16.
  • Py_BuildValue accepts B format (for bgen-generated code).


  • On Unix, fix code for finding Python installation directory so that it works when argv[0] is a relative path.
  • Added a true tnicode_internal_encode() function and fixed the unicode_internal_decode function() to support Unicode objects directly rather than by generating a copy of the object.
  • Several of the internal Unicode tables are much smaller now, and the source code should be much friendlier to weaker compilers.
  • In the garbage collector: Fixed bug in collection of tuples. Fixed bug that caused some instances to be removed from the container set while they were still live. Fixed parsing in gc.set_debug() for platforms where sizeof(long) > sizeof(int).
  • Fixed refcount problem in instance deallocation that only occurred when Py_REF_DEBUG was defined and Py_TRACE_REFS was not.
  • On Windows, getpythonregpath is now protected against null data in registry key.
  • On Unix, create .pyc/.pyo files with O_EXCL flag to avoid a race condition.

Build and platform-specific issues

  • Better support of GNU Pth via --with-pth configure option.
  • Python/C API now properly exposed to dynamically-loaded extension modules on Reliant UNIX.
  • Changes for the benefit of SunOS 4.1.4 (really!). mmapmodule.c: Don't define MS_SYNC to be zero when it is undefined. Added missing prototypes in posixmodule.c.
  • Improved support for HP-UX build. Threads should now be correctly configured (on HP-UX 10.20 and 11.00).
  • Fix largefile support on older NetBSD systems and OpenBSD by adding define for TELL64.

Tools and other miscellany

  • ftpmirror: Call to main() is wrapped in if __name__ '__main__'.
  • freeze: The modulefinder now works with 2.0 opcodes.
  • IDLE: Move hackery of sys.argv until after the Tk instance has been created, which allows the application-specific Tkinter initialization to be executed if present; also pass an explicit className parameter to the Tk() constructor.

What's new in 2.0 beta 1?

Source Incompatibilities

None. Note that 1.6 introduced several incompatibilities with 1.5.2,such as single-argument append(), connect() and bind(), and changes tostr(long) and repr(float).

Binary Incompatibilities

  • Third party extensions built for Python 1.5.x or 1.6 cannot be usedwith Python 2.0; these extensions will have to be rebuilt for Python2.0.
  • On Windows, attempting to import a third party extension built forPython 1.5.x or 1.6 results in an immediate crash; there's not much wecan do about this. Check your PYTHONPATH environment variable!
  • Python bytecode files (*.pyc and *.pyo) are not compatible betweenreleases.

Overview of Changes Since 1.6

There are many new modules (including brand new XML support throughthe xml package, and i18n support through the gettext module); a listof all new modules is included below. Lots of bugs have been fixed.

The process for making major new changes to the language has changedsince Python 1.6. Enhancements must now be documented by a PythonEnhancement Proposal (PEP) before they can be accepted.

There are several important syntax enhancements, described in moredetail below:

  • Augmented assignment, e.g. x += 1
  • List comprehensions, e.g. [x**2 for x in range(10)]
  • Extended import statement, e.g. import Module as Name
  • Extended print statement, e.g. print >> file, 'Hello'

Other important changes:

  • Optional collection of cyclical garbage

Python Enhancement Proposal (PEP)

PEP stands for Python Enhancement Proposal. A PEP is a designdocument providing information to the Python community, or describinga new feature for Python. The PEP should provide a concise technicalspecification of the feature and a rationale for the feature.

We intend PEPs to be the primary mechanisms for proposing newfeatures, for collecting community input on an issue, and fordocumenting the design decisions that have gone into Python. The PEPauthor is responsible for building consensus within the community anddocumenting dissenting opinions.

The PEPs are available here.

Augmented Assignment

This must have been the most-requested feature of the past years!Eleven new assignment operators were added:

For example,

is similar to

except that A is evaluated only once (relevant when A is somethinglike dict[index].attr).

However, if A is a mutable object, A may be modified in place. Thus,if A is a number or a string, A += B has the same effect as A = A+B(except A is only evaluated once); but if a is a list, A += B has thesame effect as A.extend(B)!

Python 2d list size

Classes and built-in object types can override the new operators inorder to implement the in-place behavior; the not-in-place behavior isused automatically as a fallback when an object doesn't implement thein-place behavior. For classes, the method name is derived from themethod name for the corresponding not-in-place operator by insertingan 'i' in front of the name, e.g. __iadd__ implements in-place__add__.


Augmented assignment was implemented by Thomas Wouters.

List Comprehensions

This is a flexible new notation for lists whose elements are computedfrom another list (or lists). The simplest form is:

For example, [i**2 for i in range(4)] yields the list [0, 1, 4, 9].This is more efficient than a for loop with a list.append() call.

You can also add a condition:

For example, [w for w in words if w w.lower()] would yield the listof words that contain no uppercase characters. This is more efficientthan a for loop with an if statement and a list.append() call.

You can also have nested for loops and more than one 'if' clause. Forexample, here's a function that flattens a sequence of sequences::

This prints

List comprehensions originated as a patch set from Greg Ewing; SkipMontanaro and Thomas Wouters also contributed. Described by PEP 202.

Extended Import Statement

Many people have asked for a way to import a module under a differentname. This can be accomplished like this:

but this common idiom gets old quickly. A simple extension of theimport statement now allows this to be written as follows:

There's also a variant for 'from ... import':

This also works with packages; e.g. you can write this:

Note that 'as' is not a new keyword - it is recognized only in thiscontext (this is only possible because the syntax for the importstatement doesn't involve expressions).

Implemented by Thomas Wouters. Described by PEP 221.

Extended Print Statement

Easily the most controversial new feature, this extension to the printstatement adds an option to make the output go to a different filethan the default sys.stdout.

For example, to write an error message to sys.stderr, you can nowwrite:

As a special feature, if the expression used to indicate the fileevaluates to None, the current value of sys.stdout is used. Thus:

is equivalent to

Design and implementation by Barry Warsaw. Described by PEP 214.

Optional Collection of Cyclical Garbage

Python is now equipped with a garbage collector that can hunt downcyclical references between Python objects. It's no replacement forreference counting; in fact, it depends on the reference counts beingcorrect, and decides that a set of objects belong to a cycle if alltheir reference counts can be accounted for from their references toeach other. This devious scheme was first proposed by Eric Tiedemann,and brought to implementation by Neil Schemenauer.

There's a module 'gc' that lets you control some parameters of thegarbage collection. There's also an option to the configure scriptthat lets you enable or disable the garbage collection. In 2.0b1,it's on by default, so that we (hopefully) can collect decent userexperience with this new feature. There are some questions about itsperformance. If it proves to be too much of a problem, we'll turn itoff by default in the final 2.0 release.

Smaller Changes

A new function zip() was added. zip(seq1, seq2, ...) is equivalent tomap(None, seq1, seq2, ...) when the sequences have the same length;i.e. zip([1,2,3], [10,20,30]) returns [(1,10), (2,20), (3,30)]. Whenthe lists are not all the same length, the shortest list wins:zip([1,2,3], [10,20]) returns [(1,10), (2,20)]. See PEP 201.

sys.version_info is a tuple (major, minor, micro, level, serial).

Dictionaries have an odd new method, setdefault(key, default).dict.setdefault(key, default) returns dict[key] if it exists; if not,it sets dict[key] to default and returns that value. Thus:

does the same work as this common idiom:

There are two new variants of SyntaxError that are raised forindentation-related errors: IndentationError and TabError.

Changed x to consume exactly two hex digits; see PEP 223. Added Uescape that consumes exactly eight hex digits.

The limits on the size of expressions and file in Python source codehave been raised from 2**16 to 2**32. Previous versions of Pythonwere limited because the maximum argument size the Python VM acceptedwas 2**16. This limited the size of object constructor expressions,e.g. [1,2,3] or {'a':1, 'b':2}, and the size of source files. Thislimit was raised thanks to a patch by Charles Waldman that effectivelyfixes the problem. It is now much more likely that you will belimited by available memory than by an arbitrary limit in Python.

The interpreter's maximum recursion depth can be modified by Pythonprograms using sys.getrecursionlimit and sys.setrecursionlimit. Thislimit is the maximum number of recursive calls that can be made byPython code. The limit exists to prevent infinite recursion fromoverflowing the C stack and causing a core dump. The default value is1000. The maximum safe value for a particular platform can be foundby running Misc/

Python 2

New Modules and Packages

atexit - for registering functions to be called when Python exits.

imputil - Greg Stein's alternative API for writing custom importhooks.

pyexpat - an interface to the Expat XML parser, contributed by PaulPrescod.

xml - a new package with XML support code organized (so far) in threesubpackages: xml.dom, xml.sax, and xml.parsers. Describing thesewould fill a volume. There's a special feature whereby auser-installed package named _xmlplus overrides the standardxmlpackage; this is intended to give the XML SIG a hook to distributebackwards-compatible updates to the standard xml package.

webbrowser - a platform-independent API to launch a web browser.

Changed Modules

array - new methods for array objects: count, extend, index, pop, andremove

binascii - new functions b2a_hex and a2b_hex that convert betweenbinary data and its hex representation

calendar - Many new functions that support features including controlover which day of the week is the first day, returning strings insteadof printing them. Also new symbolic constants for days of week,e.g. MONDAY, ..., SUNDAY.

cgi - FieldStorage objects have a getvalue method that works like adictionary's get method and returns the value attribute of the object.

ConfigParser - The parser object has new methods has_option,remove_section, remove_option, set, and write. They allow the moduleto be used for writing config files as well as reading them.

ftplib - ntransfercmd(), transfercmd(), and retrbinary() all nowoptionally support the RFC 959 REST command.

gzip - readline and readlines now accept optional size arguments

httplib - New interfaces and support for HTTP/1.1 by Greg Stein. Seethe module doc strings for details.

locale - implement getdefaultlocale for Win32 and Macintosh

marshal - no longer dumps core when marshaling deeply nested orrecursive data structures

os - new functions isatty, seteuid, setegid, setreuid, setregid

os/popen2 - popen2/popen3/popen4 support under Windows. popen2/popen3support under Unix.

os/pty - support for openpty and forkpty

os.path - fix semantics of os.path.commonprefix

smtplib - support for sending very long messages

socket - new function getfqdn()

readline - new functions to read, write and truncate history files.The readline section of the library reference manual contains anexample.

select - add interface to poll system call

shutil - new copyfileobj function

SimpleHTTPServer, CGIHTTPServer - Fix problems with buffering in theHTTP server.

Tkinter - optimization of function flatten

urllib - scans environment variables for proxy configuration,e.g. http_proxy.

whichdb - recognizes dumbdbm format

Obsolete Modules

None. However note that 1.6 made a whole slew of modules obsolete:stdwin, soundex, cml, cmpcache, dircache, dump, find, grep, packmail,poly, zmod, strop, util, whatsound.

Changed, New, Obsolete Tools


C-level Changes

Several cleanup jobs were carried out throughout the source code.

All C code was converted to ANSI C; we got rid of all uses of thePy_PROTO() macro, which makes the header files a lot more readable.

Most of the portability hacks were moved to a new header file,pyport.h; several other new header files were added and some oldheader files were removed, in an attempt to create a more rational setof header files. (Few of these ever need to be included explicitly;they are all included by Python.h.)

Trent Mick ensured portability to 64-bit platforms, under both Linuxand Win64, especially for the new Intel Itanium processor. Mick alsoadded large file support for Linux64 and Win64.

The C APIs to return an object's size have been update to consistentlyuse the form PyXXX_Size, e.g. PySequence_Size and PyDict_Size. Inprevious versions, the abstract interfaces used PyXXX_Length and theconcrete interfaces used PyXXX_Size. The old names,e.g. PyObject_Length, are still available for backwards compatibilityat the API level, but are deprecated.

The PyOS_CheckStack function has been implemented on Windows byFredrik Lundh. It prevents Python from failing with a stack overflowon Windows.

The GC changes resulted in creation of two new slots on object,tp_traverse and tp_clear. The augmented assignment changes result inthe creation of a new slot for each in-place operator.

The GC API creates new requirements for container types implemented inC extension modules. See Include/objimpl.h for details.

Python 2d List

PyErr_Format has been updated to automatically calculate the size ofthe buffer needed to hold the formatted result string. This changeprevents crashes caused by programmer error.

New C API calls: PyObject_AsFileDescriptor, PyErr_WriteUnraisable.

PyRun_AnyFileEx, PyRun_SimpleFileEx, PyRun_FileEx - New functionsthat are the same as their non-Ex counterparts except they take anextra flag argument that tells them to close the file when done.

XXX There were other API changes that should be fleshed out here.

Python 2d Drawing Libraries

Windows Changes

Python 2 Movie

New popen2/popen3/peopen4 in os module (see Changed Modules above).

os.popen is much more usable on Windows 95 and 98. See MicrosoftKnowledge Base article Q150956. The Win9x workaround described thereis implemented by the new w9xpopen.exe helper in the root of yourPython installation. Note that Python uses this internally; it is nota standalone program.

Administrator privileges are no longer required to install Pythonon Windows NT or Windows 2000. If you have administrator privileges,Python's registry info will be written under HKEY_LOCAL_MACHINE.Otherwise the installer backs off to writing Python's registry infounder HKEY_CURRENT_USER. The latter is sufficient for all 'normal'uses of Python, but will prevent some advanced uses from working(for example, running a Python script as an NT service, or possiblyfrom CGI).

[This was new in 1.6] The installer no longer runs a separate Tcl/Tkinstaller; instead, it installs the needed Tcl/Tk files directly in thePython directory. If you already have a Tcl/Tk installation, thiswastes some disk space (about 4 Megs) but avoids problems withconflicting Tcl/Tk installations, and makes it much easier for Pythonto ensure that Tcl/Tk can find all its files.

[This was new in 1.6] The Windows installer now installs by default inPython20 on the default volume, instead of Program FilesPython-2.0.

Updates to the changes between 1.5.2 and 1.6

The 1.6 NEWS file can't be changed after the release is done, so hereis some late-breaking news:

New APIs in normalize(), getdefaultlocale(), resetlocale(),and changes to getlocale() and setlocale().

The new module is now enabled per default.

It is not true that the encodings codecs cannot be used for normalstrings: the string.encode() (which is also present on 8-bit strings!) allows using them for 8-bit strings too, e.g. to convert files fromcp1252 (Windows) to latin-1 or vice-versa.

Japanese codecs are available from Tamito KAJIYAMA:


Check out our guide for installing Python 3 on Linux.

The latest versions of CentOS, Red Hat Enterprise Linux (RHEL) and Ubuntucome with Python 2.7 out of the box.

To see which version of Python you have installed, open a command prompt and run

However, with the growing popularity of Python 3, some distributions, such asFedora, don’t come with Python 2 pre-installed. You can install the python2package with your distribution package manager:

You do not need to install or configure anything else to use Python. Havingsaid that, I would strongly recommend that you install the tools and librariesdescribed in the next section before you start building Python applicationsfor real-world use. In particular, you should always install Setuptools and pip, asit makes it much easier for you to use other third-party Python libraries.

Setuptools & Pip¶

The two most crucial third-party Python packages are setuptools and pip.

Once installed, you can download, install and uninstall any compliant Python softwareproduct with a single command. It also enables you to add this network installationcapability to your own Python software with very little work.

Python 2.7.9 and later (on the python2 series), and Python 3.4 and later includepip by default.

To see if pip is installed, open a command prompt and run

To install pip, follow the official pip installation guide - this will automatically install the latest version of setuptools.

Virtual Environments¶

A Virtual Environment is a tool to keep the dependencies required by different projectsin separate places, by creating virtual Python environments for them. It solves the“Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keepsyour global site-packages directory clean and manageable.

For example, you can work on a project which requires Django 1.10 while alsomaintaining a project which requires Django 1.8.

To start using this and see more information: Virtual Environments docs.

You can also use virtualenvwrapper to make it easier tomanage your virtual environments.

This page is a remixed version of another guide,which is available under the same license.