code style and readability [was: Re: Checking the boolean value of a collection]

Larry Bates larry.bates at
Sat Sep 13 20:25:02 CEST 2008

Bruno Desthuilliers wrote:
> Bruno Desthuilliers a écrit :
>> Larry Bates a écrit :
>> (snip)
>>> IMHO it reads better if you use the __call__ method of the class to 
>>> return the value 
>> IMHO, it makes no sense at all to abuse the __call__ magic method here.
> Sorry - after a more careful re-read of other posts in the thread, it 
> might make sense, given the use case :
> condition = FolderInUse(core)
> if condition.true_for(folder):
>    # code here
> but then, a plain function (or a partial) might be even better - that 
> is, if the FolderInUse class doesn't have other responsabilities.

Sorry but I respectfully disagree that this is "abuse" of the __call__ method. 
I do agree that a plain function probably makes more sense but it appears that 
the class does "other"things because of references to other class instances, etc.

I also have a personal dislike for early returns because I've found it makes it 
harder insert execution trace logging into the code.  Just my experience.


More information about the Python-list mailing list