<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>On Mar 3, 2013, at 7:42, João Bernardo <<a href="mailto:jbvsmo@gmail.com">jbvsmo@gmail.com</a>> wrote:</div><div><br></div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">

<div>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.</div>

</div></blockquote></div><br></div><div class="gmail_extra">If I wanted to write a lot of boring duplicated code, I ought to use Java instead<span id="result_box" class="" lang="en"><span class=""></span></span>. If I can't write it in a single code base (either using "2to3" or "six" or similar) I don't write it.<br>

<br></div></div>
</blockquote>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.<div><br></div><div>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?</div><div><br></div></body></html>