# 9 New and Improved Modules

- The `xmlrpclib` module was contributed to the standard library by Fredrik Lundh, provding support for writing XML-RPC clients. XML-RPC is a simple remote procedure call protocol built on top of HTTP and XML. For example, the following snippet retrieves a list of RSS channels from the O'Reilly Network, and then lists the recent headlines for one channel:

        import xmlrpclib
        s = xmlrpclib.Server(
              'http://www.oreillynet.com/meerkat/xml-rpc/server.php')
        channels = s.meerkat.getChannels()
        # channels is a list of dictionaries, like this:
        # [{'id': 4, 'title': 'Freshmeat Daily News'}
        #  {'id': 190, 'title': '32Bits Online'},
        #  {'id': 4549, 'title': '3DGamers'}, ... ]

        # Get the items for one channel
        items = s.meerkat.getItems( {'channel': 4} )

        # 'items' is another list of dictionaries, like this:
        # [{'link': 'http://freshmeat.net/releases/52719/',
        #   'description': 'A utility which converts HTML to XSL FO.',
        #   'title': 'html2fo 0.3 (Default)'}, ... ]

  The `SimpleXMLRPCServer` module makes it easy to create straightforward XML-RPC servers. See http://www.xmlrpc.com/ for more information about XML-RPC.

- The new `hmac` module implements the HMAC algorithm described by RFC 2104. (Contributed by Gerhard Häring.)

- Several functions that originally returned lengthy tuples now return pseudo-sequences that still behave like tuples but also have mnemonic attributes such as memberst_mtime or `tm_year`. The enhanced functions include `stat()`, `fstat()`, `statvfs()`, and `fstatvfs()` in the `os` module, and `localtime()`, `gmtime()`, and `strptime()` in the `time` module.

  For example, to obtain a file's size using the old tuples, you'd end up writing something like `file_size = os.stat(filename)[stat.ST_SIZE]`, but now this can be written more clearly as `file_size = os.stat(filename).st_size`.

  The original patch for this feature was contributed by Nick Mathewson.

- The Python profiler has been extensively reworked and various errors in its output have been corrected. (Contributed by Fred Fred L. Drake, Jr. and Tim Peters.)

- The `socket` module can be compiled to support IPv6; specify the --enable-ipv6 option to Python's configure script. (Contributed by Jun-ichiro ``itojun'' Hagino.)

- Two new format characters were added to the `struct` module for 64-bit integers on platforms that support the C `long long` type. "`q`" is for a signed 64-bit integer, and "`Q`" is for an unsigned one. The value is returned in Python's long integer type. (Contributed by Tim Peters.)

- In the interpreter's interactive mode, there's a new built-in function `help()` that uses the `pydoc` module introduced in Python 2.1 to provide interactive help. `help(object)` displays any available help text about object. `help()` with no argument puts you in an online help utility, where you can enter the names of functions, classes, or modules to read their help text. (Contributed by Guido van Rossum, using Ka-Ping Yee's `pydoc` module.)

- Various bugfixes and performance improvements have been made to the SRE engine underlying the `re` module. For example, the `re.sub()` and `re.split()` functions have been rewritten in C. Another contributed patch speeds up certain Unicode character ranges by a factor of two, and a new `finditer()` method that returns an iterator over all the non-overlapping matches in a given string. (SRE is maintained by Fredrik Lundh. The BIGCHARSET patch was contributed by Martin von Löwis.)

- The `smtplib` module now supports RFC 2487, ``Secure SMTP over TLS'', so it's now possible to encrypt the SMTP traffic between a Python program and the mail transport agent being handed a message. `smtplib` also supports SMTP authentication. (Contributed by Gerhard Häring.)

- The `imaplib` module, maintained by Piers Lauder, has support for several new extensions: the NAMESPACE extension defined in RFC 2342, SORT, GETACL and SETACL. (Contributed by Anthony Baxter and Michel Pelletier.)

- The `rfc822` module's parsing of email addresses is now compliant with RFC 2822, an update to RFC 822. (The module's name is not going to be changed to "`rfc2822`".) A new package, `email`, has also been added for parsing and generating e-mail messages. (Contributed by Barry Warsaw, and arising out of his work on Mailman.)

- The `difflib` module now contains a new `Differ` class for producing human-readable lists of changes (a ``delta'') between two sequences of lines of text. There are also two generator functions, `ndiff()` and `restore()`, which respectively return a delta from two sequences, or one of the original sequences from a delta. (Grunt work contributed by David Goodger, from ndiff.py code by Tim Peters who then did the generatorization.)

- New constants `ascii_letters`, `ascii_lowercase`, and `ascii_uppercase` were added to the `string` module. There were several modules in the standard library that used `string.letters` to mean the ranges A-Za-z, but that assumption is incorrect when locales are in use, because `string.letters` varies depending on the set of legal characters defined by the current locale. The buggy modules have all been fixed to use `ascii_letters` instead. (Reported by an unknown person; fixed by Fred L. Drake, Jr.)

- The `mimetypes` module now makes it easier to use alternative MIME-type databases by the addition of a `MimeTypes` class, which takes a list of filenames to be parsed. (Contributed by Fred L. Drake, Jr.)

- A `Timer` class was added to the `threading` module that allows scheduling an activity to happen at some future time. (Contributed by Itamar Shtull-Trauring.)