[Python-Dev] Breaking undocumented API (original) (raw)
Michael Foord fuzzyman at voidspace.org.uk
Thu Nov 11 12:51:26 CET 2010
- Previous message: [Python-Dev] Breaking undocumented API
- Next message: [Python-Dev] Breaking undocumented API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10/11/2010 15:48, R. David Murray wrote:
On Wed, 10 Nov 2010 13:12:09 +0900, "Stephen J. Turnbull"<stephen at xemacs.org> wrote:
Nick Coghlan writes:
> > Module writers who compound the error by expecting to be imported > > this way, thereby bogarting the global namespace for their own > > purposes, should be fish-slapped. ;) > > Be prepared to fish-slap all of python-dev then - we use precisely > this technique to support optional acceleration modules. The pure > Python versions of pairs like profile/profile and heapq/heapq > include a try/except block at the end that does the equivalent of: > > try: > from accelerated import * # Allow accelerated overrides > except ImportError: > pass # Use pure Python versions But these identifiers will appear at the module level, not global, no? Otherwise this technique couldn't be used. I don't really understand what Tres is talking about when he writes "modules that expect to be imported this way". The imported module shouldn't care, no? This is an issue for the importing code to deal with. I think Tres was referring to certain packages (which shall remain nameless since I don't feel like googling to find one) whose documentation recommends the 'from import *' methodology.
Contenders include popular libraries like fabric and django:
http://docs.fabfile.org/0.9.2/usage/fabfiles.html http://docs.djangoproject.com/en/1.2/intro/tutorial03/
All the best,
Michael
At least that's how I read "Module writers who..." (that is, he's not saying the module expects to be imported that way). [*]
-- R. David Murray www.bitdance.com [*] although reading that sentence literally, the thought of such a module writer themselves being imported that way (a la Tron) has a certain charm....
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
--
READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.
- Previous message: [Python-Dev] Breaking undocumented API
- Next message: [Python-Dev] Breaking undocumented API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]