[Python-3000] stdlib reorganization

Tim Hochberg tim.hochberg at ieee.org
Wed May 31 16:46:24 CEST 2006


The more examples I see of the 'py' and 'site' top level namespaces, the 
less I like them. Let's dispose of 'site' first; it's been common to 
show examples like:

     from gui import wx

However, wx currently, and presumably for the forseeable future, lives 
in site packages, so we'd actually have something like:

     from site.gui import wx
     from site.gui import pygui
     from py.gui import tkinter

That seems confusing and suboptimal. So, presumably what we want is for 
packages that get installed under site-packages to logically live under 
the main headings so that, for example, all of the above imports would 
be "from gui ...".

That eliminates most of the uses for 'site' and if 'site' is gone I fail 
to see much use for the 'py' package either. Let's just ditch them both 
and save ourselves a layer of cruft.

On a slightly different topic, the library reorganization only seems 
useful if it's accompanied by some increased smarts in either the import 
machinery or the installation code such that one could do:

     >>> import gui
     >>> dir(gui)
     ['wx', 'tkinter', 'pygui']
     >>> help(gui)
     wx - GUI toolkit based on wxWidgets
     tkinter - GUI toolkit based on TK
     pygui - Another GUI toolkit

You don't want to import the full packages most of the time, so perhaps 
at least part of the smarts needs to be in the installer. I any event, 
reorganizing the standard lib seems at best a minor upgrade if it 
doesn't also support introspection.

I would be nice to also be able to inquire about what top level packages 
were available, but I'm not sure how to spell that since I just banished 
'py' ;-|  Perhaps:

    >>> import sys
    >>> dir(sys.packages)
    ['gui', 'web', 'database', ....]

Regards,

-tim



More information about the Python-3000 mailing list