
On 24 March 2011 02:16, Michael Foord <fuzzyman@voidspace.org.uk> wrote:
On 24/03/2011 02:06, Jesus Cea wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 23/03/11 20:56, Georg Brandl wrote:
For 3.3, I'd like to revive the tradition of listing planned large-scale changes in the PEP.
I want to integrate dependence injection in the stdlib, specially in libs creating sockets. This would be an optional feature.
The idea would be, for instance, that smtplib could call an optional constructor to create a socket-like object, if some is provided.
That would break the implicit dependency with sockets, reduce monkey-patching need, and ease testing the libs.
In general I dislike dependency injection if it's only done for testability. With monkey patching (if done right) you can safely test Python code without messing with your public interfaces just to make code testable.
Though in this case this sounds interesting to me as it would allow using stdlib modules with e.g. "green" sockets from eventlet or gevent without having to revert to monkey patching (which I don't mind for testing but dislike for production). In a way I'm always a little disappointed when a library uses sockets out of my reach, ideally you'd be able to use a library abstracted away from this so you can plug in into async frameworks and other things the author didn't foresee. Regards Floris -- Debian GNU/Linux -- The Power of Freedom www.debian.org | www.gnu.org | www.kernel.org