Maintaining a backported module

Ethan Furman ethan at stoneleaf.us
Thu Oct 24 15:42:33 EDT 2013


On 10/24/2013 01:37 AM, Mark Lawrence wrote:
> On 24/10/2013 07:30, Ethan Furman wrote:
>> On 10/23/2013 09:54 PM, Steven D'Aprano wrote:
>>>
>>> I'm looking for advice on best practices for doing so. Any suggestions
>>> for managing bug fixes and enhancements to two separate code-bases
>>> without them diverging too much?
>>
>> Confining your code to the intersection of 2.7 and 3.x is probably going
>> to be the easiest thing to do as 2.7 has a bunch of 3.x features.
>>
>> Sadly, when I backported Enum I was targeting 2.5 - 3.x because I have
>> systems still running 2.5.  That was *not* a fun experience.  :(
>>
>> --
>> ~Ethan~
>
> Have you or could you publish anything regarding your experiences, I
> suspect it would be an enlightening read for a lot of us?

The only thing I can add to what's already been posted in this thread 
(and it was advice I got from Barry -- Thanks, Barry! :) is when your 
class structure cannot be written the same in both 2 and 3 (because, for 
example, you are using metaclasses) then you have to define your 
methods outside of a class, store them in a dictionary, and then use 
type to create the class.  You can look at Enum for an example (his or 
mine ;).

--
~Ethan~




More information about the Python-list mailing list