[Python-Dev] Breaking undocumented API

Tres Seaver tseaver at palladion.com
Tue Nov 9 23:12:00 CET 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/09/2010 03:48 PM, Toshio Kuratomi wrote:

> I think there's a valid case for bogarting the namespace in this instance,
> but let me know if there's a better way to do it::
> 
> # Method to use system libraries if available, otherwise use a bundled copy,
> # aka: make both system packagers and developers happy::
> 
> 
> Relevant directories and files for this module::
> 
> + foo/
> +- __init__.py
> ++ compat/
>  +- __init__.py
>  ++ bar/
>   +- __init__.py
>   +- _bar.py
> 
> foo/compat/bar/_bar.py is a bundled module.
> 
> foo/compat/bar/__init__.py has:
> 
> try:
>     from bar import *
>     from bar import __all__
> except ImportError::
>     from foo.compat.bar._bar import *
>     from foo.compat.bar._bar import __all__

I guess the usual caveats apply for dopplegangers / proxies. ;)


Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzZxzAACgkQ+gerLs4ltQ5UsgCfcaxeFruJCDGnxBA0ma8Pjggg
lW8AoMBx2FYg+PSA/Zbq94UbiPhKGnjO
=/8QU
-----END PGP SIGNATURE-----



More information about the Python-Dev mailing list