running python 2 vs 3

Mark Lawrence breamoreboy at
Fri Mar 21 10:40:40 CET 2014

On 21/03/2014 02:18, Chris Angelico wrote:
> On Fri, Mar 21, 2014 at 12:06 PM, Roy Smith <roy at> wrote:
>> In article <532b8f0d$0$29994$c3e8da3$5496439d at>,
>>   Steven D'Aprano <steve+comp.lang.python at> wrote:
>>> The rule of three applies here: anything you do in three different places
>>> ought to be managed by a function.
>> I prefer the rule of two :-)
> The way I explain it is: Three is a rule of thumb. Sometimes it's
> blatantly obvious at two, and other times you need four or five
> similar pieces of code before you can see which part should become the
> function. If the code's absolutely identical and reasonably
> long/complex, then yes, two's all you need, but how often is that?
> Usually it's similar, rather than congruent... err I mean identical.
> That's where the third usage comes in. Or if it's maybe 2-3 lines,
> used in two places, it doesn't necessarily need to be a function.
> Again, a third usage is a strong hint that it should be broken out.
> The rule doesn't say that anything that *isn't* in three places yet
> should *not* be broken out. :)
> ChrisA

Everybody, and especially Antipodeans, knows that there is no rule 6 and 
by definition what rule 7 is :)

My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

This email is free from viruses and malware because avast! Antivirus protection is active.

More information about the Python-list mailing list