[Python-3000] stdlib reorganization

Fernando Perez fperez.net at gmail.com
Wed May 31 15:52:04 CEST 2006


Fred L. Drake, Jr. wrote:

> On Wednesday 31 May 2006 01:49, Ronald Oussoren wrote:
>  > I can understand the wish for a toplevel package that contains the
>  > stdlib, although I don't think I agree with that.
> 
> I understand it, and mostly wish for it at this point, though I think the
> name really has to be something short to work.

I've thought about this for a while, and wondered if it wouldn't be more
palatable in conjunction with a small syntactic addition to the import
statement: 'from :'.  An example should make the idea clear, assuming 'py'
or 'std' as the canonical name for the stdlib:

from std:
  import email
  import sys
  import os

from scipy:
  import linalg
  import fft


This obviously raises the problem of offering two ways of doing the same:

from foo import bar
from foo: import bar

if the ':' is allowed but left as optional.  

Rather than having a nested stdlib, what I'd like to have is to protection
from accidental name clashes with other things.  An 'std' namespace would
future-proof the stdlib in this regard, with a minimal burden on code
writers.  I already write the above anyway in most of my code since I think
it helps clarify what comes from where, it's just that I use a comment:

# stdlib imports
import os
import sys

# third-party imports
...


If this particular approach has already been debated and rejected, please
forgive me: I did read as much as I could find on the archives first.

Cheers,

f



More information about the Python-3000 mailing list