[Python-Dev] __all__ in urllib

Skip Montanaro skip@mojam.com (Skip Montanaro)
Tue, 6 Mar 2001 07:51:49 -0600 (CST)


    Jack> I started fixing up __all__, but then I realised that this is
    Jack> probably not the right solution. 

    Jack> One is as a convenience, where the user doesn't want to prefix all
    Jack> references with xxx. but the other distinct case is in a module
    Jack> that is an extension of another module. In this second case you
    Jack> would really want to bypass this whole __all__ mechanism.

    Jack> I think that the latter is a valid use case for import *, and that
    Jack> there should be some way to get this behaviour.

Two things come to mind.  One, perhaps a more careful coding of urllib to
avoid exposing names it shouldn't export would be a better choice.  Two,
perhaps those symbols that are not documented but that would be useful when
extending urllib functionality should be documented and added to __all__.

Here are the non-module names I didn't include in urllib.__all__:

    MAXFTPCACHE
    localhost
    thishost
    ftperrors
    noheaders
    ftpwrapper
    addbase
    addclosehook
    addinfo
    addinfourl
    basejoin
    toBytes
    unwrap
    splittype
    splithost
    splituser
    splitpasswd
    splitport
    splitnport
    splitquery
    splittag
    splitattr
    splitvalue
    splitgophertype
    always_safe
    getproxies_environment
    getproxies
    getproxies_registry
    test1
    reporthook
    test
    main

None are documented, so there are no guarantees if you use them (I have
subclassed addinfourl in the past myself).

Skip