[Python-ideas] Experimental package

Andrew Barnert abarnert at yahoo.com
Sun Mar 3 17:53:31 CET 2013


On Mar 3, 2013, at 7:42, João Bernardo <jbvsmo at gmail.com> wrote:

>> Meanwhile, if you need a workaround, it's not that hard. I've got code that does this today: I have my nifty 3.3 module, and the fallback is in a separate module, so I can "import foo33 as foo" or "import foo26 as foo" as appropriate.
> 
> If I wanted to write a lot of boring duplicated code, I ought to use Java instead. If I can't write it in a single code base (either using "2to3" or "six" or similar) I don't write it.
> 
Most of the time, you can just use "for x in foo: yield foo", so you really don't need a workaround. But when that's not appropriate (e.g., for performance reasons), you generally have to implement things pretty differently anyway. You're already writing the code twice; fooling yourself into thinking otherwise doesn't help.

More importantly, you don't have to duplicate the entire module. Factor out the part that's version dependent, and create two tiny modules for the two different implementations. It ends up being two more lines of code, one level less indented, and more readable. Where's the harm?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130303/5f976fcd/attachment.html>


More information about the Python-ideas mailing list